diff --git a/0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch b/0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch new file mode 100644 index 0000000000000000000000000000000000000000..536f3dff8b0c4aabe71ba2fe7896df7ee8f5eace --- /dev/null +++ b/0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch @@ -0,0 +1,93 @@ +From 822d849ad922edc6306f96efe3e936359bb4541f Mon Sep 17 00:00:00 2001 +From: xiajingze +Date: Thu, 31 Oct 2024 16:30:51 +0800 +Subject: [PATCH] [Driver] Pass -z\ and -Wl,-z \ option to the + linker + +Signed-off-by: xiajingze +--- + clang/include/clang/Driver/Options.td | 5 +++++ + clang/lib/Driver/Driver.cpp | 18 ++++++++++++++++++ + clang/test/Driver/z-args.c | 15 +++++++++++++++ + 3 files changed, 38 insertions(+) + create mode 100644 clang/test/Driver/z-args.c + +diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td +index 344c8bd49da7..b40046a740a8 100644 +--- a/clang/include/clang/Driver/Options.td ++++ b/clang/include/clang/Driver/Options.td +@@ -886,8 +886,13 @@ def Xopenmp_target : Separate<["-"], "Xopenmp-target">, Group + def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">, Group, + HelpText<"Pass to the target offloading toolchain identified by .">, + MetaVarName<" ">; ++#ifdef BUILD_FOR_OPENEULER ++def z : JoinedOrSeparate<["-"], "z">, Flags<[LinkerInput]>, ++ HelpText<"Pass -z or -z to the linker">, MetaVarName<"">, ++#else + def z : Separate<["-"], "z">, Flags<[LinkerInput]>, + HelpText<"Pass -z to the linker">, MetaVarName<"">, ++#endif + Group; + def offload_link : Flag<["--"], "offload-link">, Group, + HelpText<"Use the new offloading linker to perform the link job.">; +diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp +index bd9db7714f95..28b33c8862e4 100644 +--- a/clang/lib/Driver/Driver.cpp ++++ b/clang/lib/Driver/Driver.cpp +@@ -2597,6 +2597,16 @@ void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC, + } + } + ++#ifdef BUILD_FOR_OPENEULER ++llvm::DenseSet ZArgsList{ ++ "defs", "muldefs", "execstack", "noexecstack", "globalaudit", "combreloc", ++ "nocombreloc", "global", "initfirst", "interpose", "lazy", "loadfltr", ++ "nocopyreloc", "nodefaultlib", "nodelete", "nodlopen", "nodump", "now", ++ "origin", "relro", "norelro", "separate-code", "noseparate-code", "common", ++ "nocommon", "text", "notext", "textoff" ++}; ++#endif ++ + bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value, + types::ID Ty, bool TypoCorrect) const { + if (!getCheckInputsExist()) +@@ -2673,6 +2683,14 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value, + if (IsCLMode() && Ty == types::TY_Object && !Value.startswith("/")) + return true; + ++#ifdef BUILD_FOR_OPENEULER ++ if (ZArgsList.find(Value) != ZArgsList.end() || ++ Value.starts_with("common-page-size=") || ++ Value.starts_with("max-page-size=") || ++ Value.starts_with("stack-size=")) ++ return true; ++#endif ++ + Diag(clang::diag::err_drv_no_such_file) << Value; + return false; + } +diff --git a/clang/test/Driver/z-args.c b/clang/test/Driver/z-args.c +new file mode 100644 +index 000000000000..83bb2b570e69 +--- /dev/null ++++ b/clang/test/Driver/z-args.c +@@ -0,0 +1,15 @@ ++// REQUIRES: build_for_openeuler ++// RUN: %clang -### -znow 2>&1 | FileCheck -check-prefix=CHECK-LINKER %s ++// CHECK-LINKER: "-z" "now" ++ ++// RUN: %clang -### -Wl,-z now 2>&1 | FileCheck -check-prefix=CHECK-WLCOMMAZ %s ++// CHECK-WLCOMMAZ: "-z" "now" ++// RUN: %clang -### -Wl,-z -Wl,now 2>&1 | FileCheck \ ++// RUN: -check-prefix=CHECK-WLCOMMAZ1 %s ++// CHECK-WLCOMMAZ1: "-z" "now" ++// RUN: %clang -### -Wl,-z -O3 now 2>&1 | FileCheck \ ++// RUN: -check-prefix=CHECK-WLCOMMAZ2 %s ++// CHECK-WLCOMMAZ2: "-z" "now" ++// RUN: %clang -### -Wl,-z stack-size=1 2>&1 | FileCheck \ ++// RUN: -check-prefix=CHECK-WLCOMMAZ3 %s ++// CHECK-WLCOMMAZ3: "-z" "stack-size=1" +\ No newline at end of file +-- +2.43.0 + diff --git a/clang.spec b/clang.spec index 2dfd58e7f9232f2d07c7f4d34e2d92cda325fe18..cf9c227300a7cd22ed952a126f8d294bb3561729 100644 --- a/clang.spec +++ b/clang.spec @@ -43,7 +43,7 @@ Name: %{pkg_name} Version: %{clang_version} -Release: 25 +Release: 26 Summary: A C language family front-end for LLVM License: NCSA @@ -73,6 +73,7 @@ Patch18: 0018-backport-Clang-Fix-build-with-GCC-14-on-ARM-78704.patch Patch19: 0019-AArch64-Support-HiSilicon-s-HIP09-Processor.patch Patch20: 0020-Backport-LoongArch-fix-and-add-some-new-support.patch Patch21: 0021-AArch64-Delete-hip09-macro.patch +Patch22: 0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch # Patches for clang-tools-extra # See https://reviews.llvm.org/D120301 @@ -417,6 +418,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build %{install_bindir}/git-clang-format %changelog +* Tue Nov 19 2024 xiajingze - 17.0.6-26 +- [Driver] Pass -z and -Wl,-z option to the linker + * Mon Nov 18 2024 xiajingze - 17.0.6-25 - [AArch64] Delete hip09 macro