internal/rosa: patch library paths
All checks were successful
Test / Create distribution (push) Successful in 49s
Test / Sandbox (push) Successful in 2m41s
Test / Hakurei (push) Successful in 3m54s
Test / ShareFS (push) Successful in 3m57s
Test / Hpkg (push) Successful in 4m36s
Test / Sandbox (race detector) (push) Successful in 5m5s
Test / Hakurei (race detector) (push) Successful in 5m59s
Test / Flake checks (push) Successful in 1m40s
All checks were successful
Test / Create distribution (push) Successful in 49s
Test / Sandbox (push) Successful in 2m41s
Test / Hakurei (push) Successful in 3m54s
Test / ShareFS (push) Successful in 3m57s
Test / Hpkg (push) Successful in 4m36s
Test / Sandbox (race detector) (push) Successful in 5m5s
Test / Hakurei (race detector) (push) Successful in 5m59s
Test / Flake checks (push) Successful in 1m40s
This removes the need for reference LDFLAGS in the standard toolchain. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -297,7 +297,6 @@ config_disable() {
|
||||
cat > /bin/gcc << EOF
|
||||
exec clang \
|
||||
-Wno-ignored-optimization-argument \
|
||||
${ROSA_CFLAGS} \
|
||||
${LDFLAGS} \
|
||||
\$@
|
||||
EOF
|
||||
|
||||
@@ -51,7 +51,6 @@ func (t Toolchain) newGo(
|
||||
"CC=cc",
|
||||
"GOCACHE=/tmp/gocache",
|
||||
"GOROOT_BOOTSTRAP=/system/go",
|
||||
"CGO_" + ldflags(false) + " -O2 -g",
|
||||
}, env), `
|
||||
mkdir /work/system
|
||||
cp -r /usr/src/go /work/system
|
||||
|
||||
@@ -19,7 +19,6 @@ func (t Toolchain) newKernel(
|
||||
t.NewMake(),
|
||||
}, extra), nil, nil, `
|
||||
export LLVM=1
|
||||
export HOSTCFLAGS="${ROSA_CFLAGS}"
|
||||
export HOSTLDFLAGS="${LDFLAGS}"
|
||||
chmod -R +w /usr/src/linux && cd /usr/src/linux
|
||||
`+script, pkg.Path(AbsUsrSrc.Append("linux"), true, pkg.NewHTTPGetTar(
|
||||
|
||||
@@ -140,8 +140,10 @@ func (t Toolchain) newLLVM(variant string, attr *llvmAttr) pkg.Artifact {
|
||||
|
||||
if attr.flags&llvmProjectClang != 0 {
|
||||
cache = append(cache,
|
||||
[2]string{"CLANG_DEFAULT_LINKER", "lld"},
|
||||
[2]string{"CLANG_DEFAULT_CXX_STDLIB", "libc++"},
|
||||
[2]string{"CLANG_DEFAULT_RTLIB", "compiler-rt"},
|
||||
[2]string{"CLANG_DEFAULT_UNWINDLIB", "libunwind"},
|
||||
)
|
||||
}
|
||||
if attr.flags&llvmProjectLld != 0 {
|
||||
@@ -237,10 +239,15 @@ func (t Toolchain) NewLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
|
||||
{"LLVM_ENABLE_LIBXML2", "OFF"},
|
||||
}
|
||||
|
||||
var env []string
|
||||
if t == toolchainStage3 {
|
||||
env = []string{
|
||||
"LDFLAGS=" + earlyLDFLAGS(false),
|
||||
}
|
||||
}
|
||||
|
||||
compilerRT = t.newLLVM("compiler-rt", &llvmAttr{
|
||||
env: []string{
|
||||
ldflags(false),
|
||||
},
|
||||
env: env,
|
||||
cmake: [][2]string{
|
||||
// libc++ not yet available
|
||||
{"CMAKE_CXX_COMPILER_TARGET", ""},
|
||||
@@ -281,20 +288,17 @@ ln -s \
|
||||
|
||||
musl = t.NewMusl(&MuslAttr{
|
||||
Extra: []pkg.Artifact{compilerRT},
|
||||
Env: []string{
|
||||
ldflags(false),
|
||||
Env: slices.Concat(env, []string{
|
||||
"CC=clang",
|
||||
"LIBCC=/system/lib/clang/21/lib/" +
|
||||
triplet() + "/libclang_rt.builtins.a",
|
||||
"AR=ar",
|
||||
"RANLIB=ranlib",
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
runtimes = t.newLLVM("runtimes", &llvmAttr{
|
||||
env: []string{
|
||||
ldflags(false),
|
||||
},
|
||||
env: env,
|
||||
flags: llvmRuntimeLibunwind | llvmRuntimeLibcxx | llvmRuntimeLibcxxABI,
|
||||
cmake: slices.Concat([][2]string{
|
||||
// libc++ not yet available
|
||||
@@ -320,9 +324,7 @@ ln -s \
|
||||
|
||||
clang = t.newLLVM("clang", &llvmAttr{
|
||||
flags: llvmProjectClang | llvmProjectLld,
|
||||
env: slices.Concat(clangExtraEnv, []string{
|
||||
ldflags(false),
|
||||
}),
|
||||
env: slices.Concat(clangExtraEnv, env),
|
||||
cmake: slices.Concat([][2]string{
|
||||
{"LLVM_TARGETS_TO_BUILD", target},
|
||||
{"CMAKE_CROSSCOMPILING", "OFF"},
|
||||
@@ -342,17 +344,7 @@ ninja check-all
|
||||
`,
|
||||
|
||||
patches: [][2]string{
|
||||
{"xfail-broken-tests", `diff --git a/clang/test/Driver/hexagon-toolchain-linux.c b/clang/test/Driver/hexagon-toolchain-linux.c
|
||||
index e791353cca07..4efaf3948054 100644
|
||||
--- a/clang/test/Driver/hexagon-toolchain-linux.c
|
||||
+++ b/clang/test/Driver/hexagon-toolchain-linux.c
|
||||
@@ -1,3 +1,5 @@
|
||||
+// XFAIL: target={{.*-rosa-linux-musl}}
|
||||
+
|
||||
// UNSUPPORTED: system-windows
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
diff --git a/clang/test/Modules/timestamps.c b/clang/test/Modules/timestamps.c
|
||||
{"xfail-broken-tests", `diff --git a/clang/test/Modules/timestamps.c b/clang/test/Modules/timestamps.c
|
||||
index 50fdce630255..4b4465a75617 100644
|
||||
--- a/clang/test/Modules/timestamps.c
|
||||
+++ b/clang/test/Modules/timestamps.c
|
||||
@@ -389,6 +381,86 @@ index cdbf21fb9026..dd052858700d 100644
|
||||
|
||||
if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl())
|
||||
addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
|
||||
`},
|
||||
|
||||
{"path-system-libraries", `diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
index 8d3775de9be5..1e126e2d6f24 100644
|
||||
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
@@ -463,6 +463,15 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
|
||||
if (!TC.isCrossCompiling())
|
||||
addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
|
||||
|
||||
+ const std::string RosaSuffix = "-rosa-linux-musl";
|
||||
+ if (TC.getTripleString().size() > RosaSuffix.size() &&
|
||||
+ std::equal(RosaSuffix.rbegin(), RosaSuffix.rend(), TC.getTripleString().rbegin())) {
|
||||
+ CmdArgs.push_back("-rpath");
|
||||
+ CmdArgs.push_back("/system/lib");
|
||||
+ CmdArgs.push_back("-rpath");
|
||||
+ CmdArgs.push_back(("/system/lib/" + TC.getTripleString()).c_str());
|
||||
+ }
|
||||
+
|
||||
for (const auto &II : Inputs) {
|
||||
// If the current tool chain refers to an OpenMP offloading host, we
|
||||
// should ignore inputs that refer to OpenMP offloading devices -
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
index 8ac8d4eb9181..795995bb53cb 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
@@ -324,6 +324,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||
Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths);
|
||||
addPathIfExists(D, concat(SysRoot, "/libo32"), Paths);
|
||||
addPathIfExists(D, concat(SysRoot, "/usr/libo32"), Paths);
|
||||
+ addPathIfExists(D, concat(SysRoot, "/system/libo32"), Paths);
|
||||
}
|
||||
Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
|
||||
|
||||
@@ -343,16 +344,20 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||
|
||||
addPathIfExists(D, concat(SysRoot, "/usr/lib", MultiarchTriple), Paths);
|
||||
addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir), Paths);
|
||||
+ addPathIfExists(D, concat(SysRoot, "/system/lib", MultiarchTriple), Paths);
|
||||
+ addPathIfExists(D, concat(SysRoot, "/system", OSLibDir), Paths);
|
||||
if (IsRISCV) {
|
||||
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
|
||||
addPathIfExists(D, concat(SysRoot, "/", OSLibDir, ABIName), Paths);
|
||||
addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir, ABIName), Paths);
|
||||
+ addPathIfExists(D, concat(SysRoot, "/system", OSLibDir, ABIName), Paths);
|
||||
}
|
||||
|
||||
Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
|
||||
|
||||
addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
|
||||
addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
|
||||
+ addPathIfExists(D, concat(SysRoot, "/system/lib"), Paths);
|
||||
}
|
||||
|
||||
ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
|
||||
@@ -457,6 +462,11 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
|
||||
return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
|
||||
}
|
||||
if (Triple.isMusl()) {
|
||||
+ const std::string RosaSuffix = "-rosa-linux-musl";
|
||||
+ if (Triple.str().size() > RosaSuffix.size() &&
|
||||
+ std::equal(RosaSuffix.rbegin(), RosaSuffix.rend(), Triple.str().rbegin()))
|
||||
+ return "/system/bin/linker";
|
||||
+
|
||||
std::string ArchName;
|
||||
bool IsArm = false;
|
||||
|
||||
diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
|
||||
index 64324a3f8b01..15ce70b68217 100644
|
||||
--- a/clang/tools/clang-installapi/Options.cpp
|
||||
+++ b/clang/tools/clang-installapi/Options.cpp
|
||||
@@ -515,7 +515,7 @@ bool Options::processFrontendOptions(InputArgList &Args) {
|
||||
FEOpts.FwkPaths = std::move(FrameworkPaths);
|
||||
|
||||
// Add default framework/library paths.
|
||||
- PathSeq DefaultLibraryPaths = {"/usr/lib", "/usr/local/lib"};
|
||||
+ PathSeq DefaultLibraryPaths = {"/usr/lib", "/system/lib", "/usr/local/lib"};
|
||||
PathSeq DefaultFrameworkPaths = {"/Library/Frameworks",
|
||||
"/System/Library/Frameworks"};
|
||||
|
||||
`},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -29,8 +29,12 @@ func (t Toolchain) NewMusl(attr *MuslAttr) pkg.Artifact {
|
||||
|
||||
target := "install"
|
||||
script := `
|
||||
mv -v /work/lib/* /work/system/lib
|
||||
rmdir -v /work/lib/
|
||||
mkdir -p /work/system/bin
|
||||
COMPAT_LINKER_NAME="ld-musl-$(uname -m).so.1"
|
||||
ln -vs ../lib/libc.so /work/system/bin/linker
|
||||
ln -vs libc.so "/work/system/lib/${COMPAT_LINKER_NAME}"
|
||||
rm -v "/work/lib/${COMPAT_LINKER_NAME}"
|
||||
rmdir -v /work/lib
|
||||
`
|
||||
if attr.Headers {
|
||||
target = "install-headers"
|
||||
|
||||
@@ -39,6 +39,10 @@ func (t Toolchain) NewPython() pkg.Artifact {
|
||||
t.NewLibffi(),
|
||||
}, nil, []string{
|
||||
"EXTRATESTOPTS=-j0 -x " + strings.Join(skipTests, " -x "),
|
||||
|
||||
// _ctypes appears to infer something from the linker name
|
||||
"LDFLAGS=-Wl,--dynamic-linker=/system/lib/" +
|
||||
"ld-musl-" + linuxArch() + ".so.1",
|
||||
}, `
|
||||
# test_synopsis_sourceless assumes this is writable and checks __pycache__
|
||||
chmod -R +w /usr/src/python/
|
||||
|
||||
@@ -65,10 +65,9 @@ const (
|
||||
EnvTriplet = "ROSA_TRIPLE"
|
||||
)
|
||||
|
||||
// ldflags returns LDFLAGS corresponding to triplet.
|
||||
func ldflags(static bool) string {
|
||||
s := "LDFLAGS=" +
|
||||
"-fuse-ld=lld " +
|
||||
// earlyLDFLAGS returns LDFLAGS corresponding to triplet.
|
||||
func earlyLDFLAGS(static bool) string {
|
||||
s := "-fuse-ld=lld " +
|
||||
"-L/system/lib -Wl,-rpath=/system/lib " +
|
||||
"-L/system/lib/" + triplet() + " " +
|
||||
"-Wl,-rpath=/system/lib/" + triplet() + " " +
|
||||
@@ -76,7 +75,7 @@ func ldflags(static bool) string {
|
||||
"-unwindlib=libunwind " +
|
||||
"-Wl,--as-needed"
|
||||
if !static {
|
||||
s += " -Wl,--dynamic-linker=/system/lib/ld-musl-x86_64.so.1"
|
||||
s += " -Wl,--dynamic-linker=/system/bin/linker"
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -199,7 +198,7 @@ ln -vs ../usr/bin /work/bin
|
||||
env = fixupEnviron(env, []string{
|
||||
EnvTriplet + "=" + triplet(),
|
||||
lcMessages,
|
||||
ldflags(true),
|
||||
"LDFLAGS=" + earlyLDFLAGS(true),
|
||||
}, "/system/bin",
|
||||
"/usr/bin",
|
||||
"/usr/lib/llvm/21/bin",
|
||||
@@ -220,8 +219,6 @@ ln -vs ../usr/bin /work/bin
|
||||
EnvTriplet + "=" + triplet(),
|
||||
lcMessages,
|
||||
|
||||
ldflags(false),
|
||||
|
||||
"AR=ar",
|
||||
"RANLIB=ranlib",
|
||||
"LIBCC=/system/lib/clang/21/lib/" + triplet() +
|
||||
|
||||
Reference in New Issue
Block a user