diff --git a/src/Runner.jl b/src/Runner.jl index ec3ab05d..76f45696 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -348,6 +348,15 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr end function gcc_compile_flags!(p::AbstractPlatform, flags::Vector{String} = String[]) + if Sys.islinux(p) || Sys.isfreebsd(p) + # Help GCC find its own libraries under `/opt/${target}/${target}/lib{,64}`. + # Note: we need to push them directly in 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") + append!(flags, ("-L$(dir)", "-Wl,-rpath-link,$(dir)")) + end if lock_microarchitecture append!(flags, get_march_flags(arch(p), march(p), "gcc")) end diff --git a/test/runners.jl b/test/runners.jl index 9eff61c2..0be6786b 100644 --- a/test/runners.jl +++ b/test/runners.jl @@ -128,6 +128,41 @@ end @test endswith(readchomp(iobuff), "Hello World!") end + @testset "C++ - $(platform)" for platform in platforms + ur = preferred_runner()(dir; platform=platform) + iobuff = IOBuffer() + test_c = """ + #include + class breakCCompiler; // Courtesy of Meson + int main() { + std::cout << "Hello World!" << std::endl; + return 0; + } + """ + test_script = """ + set -e + # Install `CompilerSupportLibraries_jll` v0.5.0 in the `\${prefix}` to make + # sure it doesn't break compilation of the program + mkdir -p \${prefix} + wget -qO - "https://github.com/JuliaBinaryWrappers/CompilerSupportLibraries_jll.jl/releases/download/CompilerSupportLibraries-v0.5.0%2B0/CompilerSupportLibraries.v0.5.0.\${target}-libgfortran3.tar.gz" | tar xzf - -C \${prefix} + echo '$(test_c)' > test.cpp + # Make sure we can compile successfully also when `\${libdir}` is in the + # linker search path + g++ -o test test.cpp -L\${libdir} + ./test + """ + cmd = `/bin/bash -c "$(test_script)"` + if arch(platform) == "i686" && libc(platform) == "musl" + # We can't run C++ programs for this platform + @test_broken run(ur, cmd, iobuff; tee_stream=devnull) + else + @test run(ur, cmd, iobuff; tee_stream=devnull) + seekstart(iobuff) + # Test that we get the output we expect + @test endswith(readchomp(iobuff), "Hello World!") + end + end + # This tests that compilers for all Intel Linux platforms can build a simple # Fortran program that we can also run @testset "Fortran - $(platform)" for platform in filter(p -> Sys.islinux(p) && proc_family(p) == "intel", supported_platforms()) @@ -140,6 +175,7 @@ end """ cmd = `/bin/bash -c "echo '$(test_f)' > test.f && gfortran -o test test.f && ./test"` if arch(platform) == "i686" && libc(platform) == "musl" + # We can't run Fortran programs for this platform @test_broken run(ur, cmd, iobuff; tee_stream=devnull) else @test run(ur, cmd, iobuff; tee_stream=devnull)