Skip to content

Commit b0231bd

Browse files
authored
Add cxxstringabi mismatches to tests and $CC -lgfortran tests (#640)
* Add cxxstringabi mismatches to tests * Fix libgfortran linking on all platforms and GCC versions Also bump RootFS for a (further) improved test suite
1 parent b0e599d commit b0231bd

File tree

5 files changed

+104
-33
lines changed

5 files changed

+104
-33
lines changed

Artifacts.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,27 +2110,27 @@ os = "linux"
21102110
sha256 = "7e198fa9a95c7a3ece03c79dd3e9ee35a9e1e5737d2222987f4dbb3bf3519bf0"
21112111
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/PlatformSupport-v2020.1.15/PlatformSupport-x86_64-w64-mingw32.v2020.1.15.x86_64-linux-musl.unpacked.tar.gz"
21122112

2113-
[["Rootfs.v2020.1.29.x86_64-linux-musl.squashfs"]]
2113+
[["Rootfs.v2020.1.30.x86_64-linux-musl.squashfs"]]
21142114
arch = "x86_64"
2115-
git-tree-sha1 = "227b857e27ddbd239000a48f121b0b8ff3729387"
2115+
git-tree-sha1 = "5e71189306517438a3451807bfa920a48ecb239e"
21162116
lazy = true
21172117
libc = "musl"
21182118
os = "linux"
21192119

2120-
[["Rootfs.v2020.1.29.x86_64-linux-musl.squashfs".download]]
2121-
sha256 = "f9463d48fca4ab3db39e9d6a529cf4015f1ca239f4eb2ee475f4fb20d25332aa"
2122-
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/Rootfs-v2020.1.29/Rootfs.v2020.1.29.x86_64-linux-musl.squashfs.tar.gz"
2120+
[["Rootfs.v2020.1.30.x86_64-linux-musl.squashfs".download]]
2121+
sha256 = "13418e1e53d2d23d971f348606c7a096764afc18e9f9ad0b74c73f6290de4c11"
2122+
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/Rootfs-v2020.1.30/Rootfs.v2020.1.30.x86_64-linux-musl.squashfs.tar.gz"
21232123

2124-
[["Rootfs.v2020.1.29.x86_64-linux-musl.unpacked"]]
2124+
[["Rootfs.v2020.1.30.x86_64-linux-musl.unpacked"]]
21252125
arch = "x86_64"
2126-
git-tree-sha1 = "6aef6a25b707de7f6f9587cc57c1334a52ce5276"
2126+
git-tree-sha1 = "4ec521ae8dc18736c728ea21efdde5ce59d77756"
21272127
lazy = true
21282128
libc = "musl"
21292129
os = "linux"
21302130

2131-
[["Rootfs.v2020.1.29.x86_64-linux-musl.unpacked".download]]
2132-
sha256 = "ad6e146672e8153434df9f5d3b0229d714ae26e397cdc1db6f1b9cabe8cc914d"
2133-
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/Rootfs-v2020.1.29/Rootfs.v2020.1.29.x86_64-linux-musl.unpacked.tar.gz"
2131+
[["Rootfs.v2020.1.30.x86_64-linux-musl.unpacked".download]]
2132+
sha256 = "a52e78e937050f21787b37b4452c57d109e8ee577e0e7ef7b20100515b0ce8eb"
2133+
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/Rootfs-v2020.1.30/Rootfs.v2020.1.30.x86_64-linux-musl.unpacked.tar.gz"
21342134

21352135
[["RustBase.v1.18.3.x86_64-linux-gnu.squashfs"]]
21362136
arch = "x86_64"

src/Rootfs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ consists of four shards, but that may not always be the case.
415415
"""
416416
function choose_shards(p::Platform;
417417
compilers::Vector{Symbol} = [:c],
418-
rootfs_build::VersionNumber=v"2020.01.29",
418+
rootfs_build::VersionNumber=v"2020.01.30",
419419
ps_build::VersionNumber=v"2020.01.15",
420420
GCC_builds::Vector{GCCBuild}=available_gcc_builds,
421421
LLVM_builds::Vector{LLVMBuild}=available_llvm_builds,

src/Runner.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
198198

199199
# On macOS, if we're on an old GCC, the default -syslibroot that gets
200200
# passed to the linker isn't calculated correctly, so we have to manually set it.
201-
if select_gcc_version(p).major == 4
201+
if select_gcc_version(p).major in (4, 5)
202202
FLAGS *= " -Wl,-syslibroot,/opt/$(aatriplet(p))/$(aatriplet(p))/sys-root"
203203
end
204204
return FLAGS
@@ -212,12 +212,12 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
212212

213213
# On macOS, if we're on an old GCC, the default -syslibroot that gets
214214
# passed to the linker isn't calculated correctly, so we have to manually set it.
215-
if select_gcc_version(p).major == 4
215+
if select_gcc_version(p).major in (4, 5)
216216
FLAGS *= " -Wl,-syslibroot,/opt/$(aatriplet(p))/$(aatriplet(p))/sys-root"
217217
end
218218
return FLAGS
219219
end
220-
220+
221221
# For MacOS and FreeBSD, we don't set `-rtlib`, and FreeBSD is special-cased within the LLVM source tree
222222
# to not allow for -gcc-toolchain, which means that we have to manually add the location of libgcc_s. LE SIGH.
223223
# We do that within `clang_linker_flags()`, so that we don't get "unused argument" warnings all over the place.

test/auditing.jl

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,39 @@ end
7272
end
7373

7474
@testset "Auditor - cxxabi selection" begin
75+
libcxxstringabi_test = LibraryProduct("libcxxstringabi_test", :libcxxstringabi_test)
76+
77+
# Factor the autobuild() out
78+
function do_build(build_path, script, platform, gcc_version)
79+
autobuild(
80+
build_path,
81+
"libcxxstringabi_test",
82+
v"1.0.0",
83+
# Copy in the build_tests sources
84+
[build_tests_dir],
85+
script,
86+
# Build for this platform
87+
[platform],
88+
# The products we expect to be build
89+
[libcxxstringabi_test],
90+
# No depenedencies
91+
[];
92+
preferred_gcc_version=gcc_version
93+
)
94+
end
95+
7596
for platform in (Linux(:x86_64; compiler_abi=CompilerABI(;cxxstring_abi=:cxx03)),
7697
Linux(:x86_64; compiler_abi=CompilerABI(;cxxstring_abi=:cxx11)))
7798
# Look across multiple gcc versions; there can be tricksy interactions here
7899
for gcc_version in (v"4", v"6", v"9")
79100
# Do each build within a separate temporary directory
80101
mktempdir() do build_path
81-
libcxxstringabi_test = LibraryProduct("libcxxstringabi_test", :libcxxstringabi_test)
82-
build_output_meta = autobuild(
83-
build_path,
84-
"libcxxstringabi_test",
85-
v"1.0.0",
86-
# Copy in the libfoo sources
87-
[build_tests_dir],
88-
# Easy build script
89-
raw"""
102+
script = raw"""
90103
cd ${WORKSPACE}/srcdir/cxxstringabi_tests
91104
make install
92105
install_license /usr/share/licenses/libuv/LICENSE
93-
""",
94-
# Build for this platform
95-
[platform],
96-
# The products we expect to be build
97-
[libcxxstringabi_test],
98-
# No depenedencies
99-
[];
100-
preferred_gcc_version=gcc_version
101-
)
102-
106+
"""
107+
build_output_meta = do_build(build_path, script, platform, gcc_version)
103108
# Extract our platform's build
104109
@test haskey(build_output_meta, platform)
105110
tarball_path, tarball_hash = build_output_meta[platform][1:2]
@@ -117,9 +122,37 @@ end
117122
detected_cxxstring_abi = BinaryBuilder.detect_cxxstring_abi(oh, platform)
118123
@test detected_cxxstring_abi == cxxstring_abi(platform)
119124
end
125+
126+
# Explicitly test cxx string abi mismatches
127+
if gcc_version > v"4"
128+
script = """
129+
mkdir -p \${libdir}
130+
/opt/\${target}/bin/\${target}-g++ -fPIC \\
131+
-D_GLIBCXX_USE_CXX11_ABI=$(cxxstring_abi(platform) == :cxx03 ? "1" : "0") \\
132+
-o \${libdir}/libcxxstringabi_test.\${dlext} \\
133+
-shared \${WORKSPACE}/srcdir/cxxstringabi_tests/lib.cc
134+
install_license /usr/share/licenses/libuv/LICENSE
135+
"""
136+
@test_logs (:warn, r"ignoring our choice of compiler") match_mode=:any begin
137+
do_build(build_path, script, platform, gcc_version)
138+
end
139+
end
120140
end
121141
end
122142
end
143+
144+
# Explicitly test not setting a cxx string abi at all
145+
script = raw"""
146+
cd ${WORKSPACE}/srcdir/cxxstringabi_tests
147+
make install
148+
install_license /usr/share/licenses/libuv/LICENSE
149+
"""
150+
platform = Linux(:x86_64)
151+
mktempdir() do build_path
152+
@test_logs (:warn, r"contains std::string values") match_mode=:any begin
153+
do_build(build_path, script, platform, v"6")
154+
end
155+
end
123156
end
124157

125158

test/building.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,44 @@ shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(shards_to_test))
197197
end
198198
end
199199

200+
@testset "gfortran linking specialty flags" begin
201+
# We test things like linking against libgfortran with `$FC` on a couple of troublesome platforms
202+
for gcc_version in (v"4", v"5", v"6")
203+
mktempdir() do build_path
204+
build_output_meta = autobuild(
205+
build_path,
206+
"gfortran_flags",
207+
v"1.0.0",
208+
# No sources
209+
[],
210+
# Build the test suite, install the binaries into our prefix's `bin`
211+
raw"""
212+
# Build testsuite
213+
make -j${nproc} -sC /usr/share/testsuite/fortran/hello_world install
214+
# Install fake license just to silence the warning
215+
install_license /usr/share/licenses/libuv/LICENSE
216+
""",
217+
# Build for a few troublesome platforms
218+
[
219+
Linux(:x86_64; compiler_abi=CompilerABI(;libgfortran_version=v"3")),
220+
Linux(:powerpc64le; compiler_abi=CompilerABI(;libgfortran_version=v"3")),
221+
Linux(:armv7l; compiler_abi=CompilerABI(;libgfortran_version=v"3")),
222+
Linux(:aarch64; compiler_abi=CompilerABI(;libgfortran_version=v"3")),
223+
MacOS(:x86_64; compiler_abi=CompilerABI(;libgfortran_version=v"3")),
224+
Windows(:i686; compiler_abi=CompilerABI(;libgfortran_version=v"3")),
225+
],
226+
[ExecutableProduct("hello_world_fortran", :hello_world_fortran)],
227+
# No dependencies
228+
[];
229+
preferred_gcc_version=gcc_version,
230+
)
231+
232+
# Just a simple test to ensure that it worked.
233+
@test length(keys(build_output_meta)) == 6
234+
end
235+
end
236+
end
237+
200238
@testset "Invalid Arguments" begin
201239
mktempdir() do build_path
202240
# Test that invalid JLL names both @warn and error()

0 commit comments

Comments
 (0)