Skip to content

Commit

Permalink
enhance(libllvm): add a flag to clang so the Termux rpaths are not au…
Browse files Browse the repository at this point in the history
…tomatically added
  • Loading branch information
finagolfin committed Jul 18, 2023
1 parent 4f01e46 commit 3b316cf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/libllvm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TERMUX_PKG_LICENSE_FILE="llvm/LICENSE.TXT"
TERMUX_PKG_MAINTAINER="@finagolfin"
LLVM_MAJOR_VERSION=16
TERMUX_PKG_VERSION=${LLVM_MAJOR_VERSION}.0.6
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SHA256=ce5e71081d17ce9e86d7cbcfa28c4b04b9300f8fb7e78422b1feb6bc52c3028e
TERMUX_PKG_SRCURL=https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/llvm-project-$TERMUX_PKG_VERSION.src.tar.xz
TERMUX_PKG_HOSTBUILD=true
Expand Down
15 changes: 15 additions & 0 deletions packages/libllvm/clang-include-clang-Driver-Options.td.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 59e1337599b2..656545555349 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4879,6 +4879,10 @@ defm spec_constr_count : BooleanFFlag<"spec-constr-count">, Group<clang_ignored_
defm stack_check : BooleanFFlag<"stack-check">, Group<clang_ignored_f_Group>;
defm strength_reduce :
BooleanFFlag<"strength-reduce">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm termux_rpath : BoolFOption<"termux-rpath",
+ LangOpts<"OpenMP">, DefaultTrue,
+ NegFlag<SetFalse, [], "Disable">, PosFlag<SetTrue, [], "Enable">,
+ BothFlags<[], " setting rpaths for the Termux environment">>;
defm tls_model : BooleanFFlag<"tls-model">, Group<clang_ignored_f_Group>;
defm tracer : BooleanFFlag<"tracer">, Group<clang_ignored_gcc_optimization_f_Group>;
defm tree_dce : BooleanFFlag<"tree-dce">, Group<clang_ignored_gcc_optimization_f_Group>;
12 changes: 7 additions & 5 deletions packages/libllvm/clang-lib-Driver-ToolChains-Linux.cpp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
addPathIfExists(D, concat(SysRoot, "/usr/lib/..", OSLibDir), Paths);
if (IsRISCV) {
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
@@ -311,7 +311,18 @@
@@ -311,7 +311,20 @@
addPathIfExists(D, D.Dir + "/../lib", Paths);

addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
Expand All @@ -32,10 +32,12 @@
+ if (IsAndroid) {
+ addPathIfExists(D, concat(SysRoot, "/usr/", MultiarchTriple, "/lib"), Paths);
+ addPathIfExists(D, concat("/system/", OSLibDir), Paths);
+ if (nativeBuild)
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/lib");
+ else
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/" + MultiarchTriple + "/lib");
+ if (Args.hasFlag(options::OPT_ftermux_rpath, options::OPT_fno_termux_rpath, true)) {
+ if (nativeBuild)
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/lib");
+ else
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/" + MultiarchTriple + "/lib");
+ }
+ }
}

Expand Down

0 comments on commit 3b316cf

Please sign in to comment.