Skip to content

Commit

Permalink
[Runner] Work around wrong path of compiler libraries for riscv64. Ag…
Browse files Browse the repository at this point in the history
…ain (#407)

* [Runner] Work around wrong path of compiler libraries for riscv64. Again

* Add test of linking C++ library with gcc

* [Runner] Fix FreeBSD and add comment to explain why these flags are here
  • Loading branch information
giordano authored Jan 31, 2025
1 parent ea0b49d commit 0abbe35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,13 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
# the wrappers before any additional arguments because we want this path to have
# precedence over anything else. In this way for example we avoid libraries
# from `CompilerSupportLibraries_jll` in `${libdir}` are picked up by mistake.
dir = "/opt/$(aatriplet(p))/$(aatriplet(p))/lib" * (nbits(p) == 32 ? "" : "64")
# Note 2: Compiler libraries for riscv64 ended up in `lib/` for some reason, and
# are always in `lib/` for FreeBSD.
# Note 3: while these are technically link-only flags, link-only flags are
# written out in our wrappers as "post flags" after those passed on the command
# line, but we really need to have these flags before those to solve
# <https://github.com/JuliaPackaging/BinaryBuilderBase.jl/issues/163>.
dir = "/opt/$(aatriplet(p))/$(aatriplet(p))/lib" * (nbits(p) == 32 || arch(p) == "riscv64" || Sys.isfreebsd(p) ? "" : "64")
append!(flags, ("-L$(dir)", "-Wl,-rpath-link,$(dir)"))
end
if lock_microarchitecture
Expand Down
12 changes: 11 additions & 1 deletion test/runners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,17 @@ end
std::complex<double> z3 = add(std::complex<double>(1.,2.),std::complex<double>(4.,2.));
return 0;
}
"""
"""
main_c = """
int main(void) {
return 0;
}
"""
test_script = """
set -e
echo '$(test_cpp)' > test.cpp
echo '$(main_cpp)' > main.cpp
echo '$(main_c)' > main.c
# Make sure setting `CCACHE` doesn't affect the compiler wrappers.
export CCACHE=pwned
export USE_CCACHE=true
Expand All @@ -238,6 +244,10 @@ end
$(linker) -o main main.o test.o
# Link main program with shared library
$(linker) -o main main.o -L. -ltest
# Also make sure we can link to libtest (which may link to
# libstdc++) with gcc (as in the C compiler).
gcc -o main_c main.c -ltest -L.
"""
cmd = `/bin/bash -c "$(test_script)"`
@test run(ur, cmd, iobuff; tee_stream=devnull)
Expand Down

0 comments on commit 0abbe35

Please sign in to comment.