11using Test
22using BinaryBuilderBase
33using BinaryBuilderBase: platform_dlext, platform_exeext
4+ using Pkg
45
56@testset " Wrappers utilities" begin
67 @test nbits (Platform (" i686" , " linux" )) == 32
@@ -105,13 +106,13 @@ end
105106 end
106107 end
107108
108- # This tests that compilers for all Intel Linux platforms can build a simple
109- # C program that we can also run
109+ # This tests that compilers for all Intel Linux platforms can build simple
110+ # C, C++, Fortran programs that we can also run
110111 @testset " Compilation and running" begin
111- mktempdir () do dir
112- platforms = filter (p -> Sys. islinux (p) && proc_family (p) == " intel" , supported_platforms ())
112+ platforms = filter (p -> Sys. islinux (p) && proc_family (p) == " intel" , supported_platforms ())
113113
114- @testset " C - $(platform) " for platform in platforms
114+ @testset " C - $(platform) " for platform in platforms
115+ mktempdir () do dir
115116 ur = preferred_runner ()(dir; platform= platform)
116117 iobuff = IOBuffer ()
117118 test_c = """
@@ -127,10 +128,66 @@ end
127128 # Test that we get the output we expect
128129 @test endswith (readchomp (iobuff), " Hello World!" )
129130 end
131+ end
132+
133+ @testset " C++ - $(platform) " for platform in platforms
134+ mktempdir () do dir
135+ # Use an old GCC with libgfortran3
136+ options = (preferred_gcc_version= v " 4" , 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 `CompilerSupportLibraries_jll` v0.5.0 in the `${prefix}` to make
146+ # sure it doesn't break compilation of the program for i686-linux-gnu, see
147+ # https://github.com/JuliaPackaging/BinaryBuilderBase.jl/issues/163
148+ artifact_paths =
149+ setup_dependencies (prefix,
150+ [PackageSpec (; name= " CompilerSupportLibraries_jll" , version= " 0.5.0" )],
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_cpp = """
158+ #include <iostream>
159+ class breakCCompiler; // Courtesy of Meson
160+ int main() {
161+ std::cout << "Hello World!" << std::endl;
162+ return 0;
163+ }
164+ """
165+ test_script = """
166+ set -e
167+ echo '$(test_cpp) ' > test.cpp
168+ # Make sure we can compile successfully also when `\$ {libdir}` is in the
169+ # linker search path
170+ g++ -o test test.cpp -L\$ {libdir}
171+ ./test
172+ """
173+ cmd = ` /bin/bash -c "$(test_script) "`
174+ if arch (platform) == " i686" && libc (platform) == " musl"
175+ # We can't run C++ programs for this platform
176+ @test_broken run (ur, cmd, iobuff; tee_stream= devnull )
177+ else
178+ @test run (ur, cmd, iobuff; tee_stream= devnull )
179+ seekstart (iobuff)
180+ # Test that we get the output we expect
181+ @test endswith (readchomp (iobuff), " Hello World!" )
182+ end
183+ cleanup_dependencies (prefix, artifact_paths, concrete_platform)
184+ end
185+ end
130186
131- # This tests that compilers for all Intel Linux platforms can build a simple
132- # Fortran program that we can also run
133- @testset " Fortran - $(platform) " for platform in filter (p -> Sys. islinux (p) && proc_family (p) == " intel" , supported_platforms ())
187+ # This tests that compilers for all Intel Linux platforms can build a simple
188+ # Fortran program that we can also run
189+ @testset " Fortran - $(platform) " for platform in platforms
190+ mktempdir () do dir
134191 ur = preferred_runner ()(dir; platform= platform)
135192 iobuff = IOBuffer ()
136193 test_f = """
140197 """
141198 cmd = ` /bin/bash -c "echo '$(test_f) ' > test.f && gfortran -o test test.f && ./test"`
142199 if arch (platform) == " i686" && libc (platform) == " musl"
200+ # We can't run Fortran programs for this platform
143201 @test_broken run (ur, cmd, iobuff; tee_stream= devnull )
144202 else
145203 @test run (ur, cmd, iobuff; tee_stream= devnull )
0 commit comments