Skip to content

Commit 0abbe35

Browse files
authored
[Runner] Work around wrong path of compiler libraries for riscv64. Again (#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
1 parent ea0b49d commit 0abbe35

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Runner.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,13 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
581581
# the wrappers before any additional arguments because we want this path to have
582582
# precedence over anything else. In this way for example we avoid libraries
583583
# from `CompilerSupportLibraries_jll` in `${libdir}` are picked up by mistake.
584-
dir = "/opt/$(aatriplet(p))/$(aatriplet(p))/lib" * (nbits(p) == 32 ? "" : "64")
584+
# Note 2: Compiler libraries for riscv64 ended up in `lib/` for some reason, and
585+
# are always in `lib/` for FreeBSD.
586+
# Note 3: while these are technically link-only flags, link-only flags are
587+
# written out in our wrappers as "post flags" after those passed on the command
588+
# line, but we really need to have these flags before those to solve
589+
# <https://github.com/JuliaPackaging/BinaryBuilderBase.jl/issues/163>.
590+
dir = "/opt/$(aatriplet(p))/$(aatriplet(p))/lib" * (nbits(p) == 32 || arch(p) == "riscv64" || Sys.isfreebsd(p) ? "" : "64")
585591
append!(flags, ("-L$(dir)", "-Wl,-rpath-link,$(dir)"))
586592
end
587593
if lock_microarchitecture

test/runners.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,17 @@ end
220220
std::complex<double> z3 = add(std::complex<double>(1.,2.),std::complex<double>(4.,2.));
221221
return 0;
222222
}
223-
"""
223+
"""
224+
main_c = """
225+
int main(void) {
226+
return 0;
227+
}
228+
"""
224229
test_script = """
225230
set -e
226231
echo '$(test_cpp)' > test.cpp
227232
echo '$(main_cpp)' > main.cpp
233+
echo '$(main_c)' > main.c
228234
# Make sure setting `CCACHE` doesn't affect the compiler wrappers.
229235
export CCACHE=pwned
230236
export USE_CCACHE=true
@@ -238,6 +244,10 @@ end
238244
$(linker) -o main main.o test.o
239245
# Link main program with shared library
240246
$(linker) -o main main.o -L. -ltest
247+
248+
# Also make sure we can link to libtest (which may link to
249+
# libstdc++) with gcc (as in the C compiler).
250+
gcc -o main_c main.c -ltest -L.
241251
"""
242252
cmd = `/bin/bash -c "$(test_script)"`
243253
@test run(ur, cmd, iobuff; tee_stream=devnull)

0 commit comments

Comments
 (0)