Skip to content

Commit bc7c7ca

Browse files
committed
[Runner] Override LD_LIBRARY_PATH inside the compiler wrappers
1 parent 0a99795 commit bc7c7ca

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/Runner.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
395395
hash_args = true,
396396
allow_ccache,
397397
no_soft_float=arch(p) in ("armv6l", "armv7l"),
398+
# Override `LD_LIBRARY_PATH` to avoid external settings mess it up.
399+
env=Dict("LD_LIBRARY_PATH"=>""),
398400
)
399401
end
400402

@@ -406,6 +408,8 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
406408
compile_only_flags=clang_compile_flags!(p),
407409
link_only_flags=clang_link_flags!(p),
408410
no_soft_float=arch(p) in ("armv6l", "armv7l"),
411+
# Override `LD_LIBRARY_PATH` to avoid external settings mess it up.
412+
env=Dict("LD_LIBRARY_PATH"=>""),
409413
)
410414
end
411415

test/runners.jl

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,58 @@ end
130130
end
131131
end
132132

133+
@testset "C and link to quadmath - $(platform)" for platform in platforms
134+
mktempdir() do dir
135+
# Use a recent GCC with libgfortran5
136+
options = (preferred_gcc_version=v"9", compilers=[:c])
137+
shards = choose_shards(platform; options...)
138+
concrete_platform = get_concrete_platform(platform, shards)
139+
prefix = setup_workspace(
140+
dir,
141+
[],
142+
concrete_platform,
143+
default_host_platform;
144+
)
145+
# Install `MPICH_jll` in the `${prefix}` to make sure we can link to
146+
# libquadmath without problems, see
147+
# https://github.com/JuliaPackaging/BinaryBuilderBase.jl/pull/157#issuecomment-879263820
148+
artifact_paths =
149+
setup_dependencies(prefix,
150+
[PackageSpec(; name="MPICH_jll", version="3.4.2")],
151+
concrete_platform, verbose=false)
152+
ur = preferred_runner()(prefix.path;
153+
platform=concrete_platform,
154+
shards = shards,
155+
options...)
156+
iobuff = IOBuffer()
157+
test_c = """
158+
#include <stdio.h>
159+
int main() {
160+
printf("Hello World!\\n");
161+
return 0;
162+
}
163+
"""
164+
test_script = """
165+
set -e
166+
echo '$(test_c)' > test.c
167+
# Make sure we can compile successfully also when linking to libmpifort
168+
cc -o test test.c -L\${libdir} -lmpifort -lquadmath
169+
./test
170+
"""
171+
cmd = `/bin/bash -c "$(test_script)"`
172+
if arch(platform) == "i686" && libc(platform) == "musl"
173+
# We can't run this program for this platform
174+
@test_broken run(ur, cmd, iobuff; tee_stream=devnull)
175+
else
176+
@test run(ur, cmd, iobuff; tee_stream=devnull)
177+
seekstart(iobuff)
178+
# Test that we get the output we expect
179+
@test endswith(readchomp(iobuff), "Hello World!")
180+
end
181+
cleanup_dependencies(prefix, artifact_paths, concrete_platform)
182+
end
183+
end
184+
133185
@testset "C++ - $(platform)" for platform in platforms
134186
mktempdir() do dir
135187
# Use an old GCC with libgfortran3
@@ -167,7 +219,7 @@ end
167219
echo '$(test_cpp)' > test.cpp
168220
# Make sure we can compile successfully also when `\${libdir}` is in the
169221
# linker search path
170-
g++ -o test test.cpp -L\${libdir}
222+
c++ -o test test.cpp -L\${libdir}
171223
./test
172224
"""
173225
cmd = `/bin/bash -c "$(test_script)"`

0 commit comments

Comments
 (0)