diff --git a/llvm-build/MakeLiblzma b/llvm-build/MakeLiblzma index 157d73ae363737e6964c16f01f931a6729e25b3e..681fa4e1304f3fd528d85639633c7e5fa1e2f5b4 100644 --- a/llvm-build/MakeLiblzma +++ b/llvm-build/MakeLiblzma @@ -25,7 +25,7 @@ LDFLAGS := -shared -fuse-ld=lld -Wl,-z,relro,-z,now -Wl,-z,noexecstack TARGET := liblzma.so else ifeq ($(TARGET_TRIPLE),windows-x86_64) -CFLAGS := --target=x86_64-pc-windows-gnu --sysroot=$(SYSROOT) -D_7ZIP_ST -Wall -Werror -Wno-empty-body -Wno-enum-conversion -Wno-logical-op-parentheses -Wno-self-assign -fPIC +CFLAGS := --target=x86_64-pc-windows-gnu --sysroot=$(SYSROOT) -D_7ZIP_ST -Wall -Werror -Wno-empty-body -Wno-enum-conversion -Wno-logical-op-parentheses -Wno-self-assign -fPIC -fstack-protector-strong LDFLAGS := -shared -fuse-ld=lld --rtlib=compiler-rt -Wl,--out-implib=liblzma.dll.a TARGET := liblzma.dll TARGET_A := liblzma.dll.a diff --git a/llvm-build/build.py b/llvm-build/build.py index 90c454453b99d9c256cce185fa64a3942245d4b4..59b89e62395f7db60f6cdc63dd0ea4e6b8b796d1 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -553,7 +553,8 @@ class BuildUtils(object): subprocess.check_call(cmd, *args, **kwargs) - def force_symlink(self, src, dst): + @staticmethod + def force_symlink(src, dst): if os.path.exists(dst): os.remove(dst) os.symlink(src, dst) @@ -1161,7 +1162,8 @@ class LlvmCore(BuildUtils): '-Wl,--high-entropy-va'] ldflags.extend(ldflag) - cflag = ['-stdlib=libc++', + cflag = ['-fstack-protector-strong', + '-stdlib=libc++', '--target=x86_64-pc-windows-gnu', '-fdata-sections', '-D_LARGEFILE_SOURCE', @@ -2226,6 +2228,7 @@ class LlvmLibs(BuildUtils): cflags = ['--target=x86_64-pc-windows-gnu'] cflags.extend(('-I', os.path.join(windows_sysroot, 'include'))) + cflags.append('-fstack-protector-strong') ldflags = ['-fuse-ld=lld', '--rtlib=compiler-rt'] diff --git a/llvm-build/mingw.py b/llvm-build/mingw.py index a476cb4e9e4149ca155082ea5451b356446e1f24..969a9e8e7b3f77062aad6134a1b44154d9cdd693 100755 --- a/llvm-build/mingw.py +++ b/llvm-build/mingw.py @@ -20,7 +20,7 @@ import os import shutil import subprocess import sys - +from build import BuildUtils class BuildConfig(): @@ -221,6 +221,12 @@ class LlvmMingw(): self.check_call(cmd, env=self.env) self.check_call(['make', '-j4'], env=self.env) self.check_call(['make', 'install'], env=self.env) + # Fix for stack protection library, see: + # https://sourceforge.net/p/mingw-w64/mingw-w64/ci/10394c9a966f8e93e9e2f09677dab273a0f6c00c/ + mingw_lib_dir = os.path.join(self.prefix, 'lib') + libmingwex = os.path.join(mingw_lib_dir, 'libmingwex.a') + BuildUtils.force_symlink(libmingwex, os.path.join(mingw_lib_dir, 'libssp.a')) + BuildUtils.force_symlink(libmingwex, os.path.join(mingw_lib_dir, 'libssp_nonshared.a')) def main(clang_version, buildtools_path): diff --git a/llvm-build/python_builder.py b/llvm-build/python_builder.py index e7f8e26c04db6b6630983ece8f11edd8ad431522..92190baac7b82016f8270e5577e99e463a30b2ec 100755 --- a/llvm-build/python_builder.py +++ b/llvm-build/python_builder.py @@ -225,6 +225,7 @@ class MinGWPythonBuilder(PythonBuilder): cflags = [ f'-target {self.target_platform}', f'--sysroot={self._mingw_install_dir}', + f'-fstack-protector-strong', ] return cflags