!154 [Driver] Pass -z<arg> and -Wl,-z <arg> option to the linker
From: @xiajingze Reviewed-by: @eastb233 Signed-off-by: @eastb233
This commit is contained in:
commit
ad573df38e
@ -0,0 +1,93 @@
|
|||||||
|
From 822d849ad922edc6306f96efe3e936359bb4541f Mon Sep 17 00:00:00 2001
|
||||||
|
From: xiajingze <xiajingze1@huawei.com>
|
||||||
|
Date: Thu, 31 Oct 2024 16:30:51 +0800
|
||||||
|
Subject: [PATCH] [Driver] Pass -z\<arg\> and -Wl,-z \<arg\> option to the
|
||||||
|
linker
|
||||||
|
|
||||||
|
Signed-off-by: xiajingze <xiajingze1@huawei.com>
|
||||||
|
---
|
||||||
|
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<CompileOnly_Group>
|
||||||
|
def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">, Group<CompileOnly_Group>,
|
||||||
|
HelpText<"Pass <arg> to the target offloading toolchain identified by <triple>.">,
|
||||||
|
MetaVarName<"<triple> <arg>">;
|
||||||
|
+#ifdef BUILD_FOR_OPENEULER
|
||||||
|
+def z : JoinedOrSeparate<["-"], "z">, Flags<[LinkerInput]>,
|
||||||
|
+ HelpText<"Pass -z<arg> or -z <arg> to the linker">, MetaVarName<"<arg>">,
|
||||||
|
+#else
|
||||||
|
def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
|
||||||
|
HelpText<"Pass -z <arg> to the linker">, MetaVarName<"<arg>">,
|
||||||
|
+#endif
|
||||||
|
Group<Link_Group>;
|
||||||
|
def offload_link : Flag<["--"], "offload-link">, Group<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<StringRef> 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
|
||||||
|
|
||||||
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
Name: %{pkg_name}
|
Name: %{pkg_name}
|
||||||
Version: %{clang_version}
|
Version: %{clang_version}
|
||||||
Release: 25
|
Release: 26
|
||||||
Summary: A C language family front-end for LLVM
|
Summary: A C language family front-end for LLVM
|
||||||
|
|
||||||
License: NCSA
|
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
|
Patch19: 0019-AArch64-Support-HiSilicon-s-HIP09-Processor.patch
|
||||||
Patch20: 0020-Backport-LoongArch-fix-and-add-some-new-support.patch
|
Patch20: 0020-Backport-LoongArch-fix-and-add-some-new-support.patch
|
||||||
Patch21: 0021-AArch64-Delete-hip09-macro.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
|
# Patches for clang-tools-extra
|
||||||
# See https://reviews.llvm.org/D120301
|
# 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
|
%{install_bindir}/git-clang-format
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 19 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-26
|
||||||
|
- [Driver] Pass -z<arg> and -Wl,-z <arg> option to the linker
|
||||||
|
|
||||||
* Mon Nov 18 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-25
|
* Mon Nov 18 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-25
|
||||||
- [AArch64] Delete hip09 macro
|
- [AArch64] Delete hip09 macro
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user