From d117168eaa90d10ae902fe190eb1792819ebbaff Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Fri, 30 Aug 2024 18:13:37 +0300 Subject: [PATCH 1/2] [build] mingw-w64 project replaced libssp and libssp_nonshared with libmingwex See https://sourceforge.net/p/mingw-w64/mingw-w64/ci/10394c9a966f8e93e9e2f09677dab273a0f6c00c Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/IANROV Signed-off-by: Sukhikh Alexander --- llvm-build/build.py | 3 ++- llvm-build/mingw.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/llvm-build/build.py b/llvm-build/build.py index 90c454453b99..07e3cbe0400e 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) diff --git a/llvm-build/mingw.py b/llvm-build/mingw.py index a476cb4e9e41..969a9e8e7b3f 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): -- Gitee From 4f5b0239a534c5fcf8eb0ab7a36cfb2cfa1de84c Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Mon, 2 Sep 2024 12:28:30 +0300 Subject: [PATCH 2/2] [build] Revert temporary build hack for stack protector Issue: https://gitee.com/open_harmony/dashboard?issue_id=IANROV Revert "[R&D][Build][Windows] Fix windows platform compilation failure" This reverts commit 6fe50d71712a276759630e52cc1366e017b77432. Signed-off-by: Sukhikh Alexander --- llvm-build/MakeLiblzma | 2 +- llvm-build/build.py | 4 +++- llvm-build/python_builder.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm-build/MakeLiblzma b/llvm-build/MakeLiblzma index 157d73ae3637..681fa4e1304f 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 07e3cbe0400e..59b89e62395f 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -1162,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', @@ -2227,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/python_builder.py b/llvm-build/python_builder.py index e7f8e26c04db..92190baac7b8 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 -- Gitee