Skip to content

Commit e793cd9

Browse files
committed
Make the profile decide the float ABI it names
The staged executor takes the profile from the lock, requires it, and then dropped it -- the comment where it landed said as much: "profile is required but not yet consumed: no profile -> VITASDK_FLOAT_ABI mapping exists in CMakeLists.txt yet". So `describe --profile vita-softfp` produced a lock that said softfp and a toolchain that was hard-float, and nothing anywhere said the two disagreed. Profiles.cmake already names the worlds this tree publishes, so it is where the ABI each of them bakes in belongs, next to the name. CMakeLists takes VITASDK_PROFILE, refuses one the tree does not publish, and derives the float ABI and the world's arch from it; build-host.sh passes it in both cmake invocations, since stage 1 builds the sysroot the later stages import. A profile wins over VITASDK_FLOAT_ABI, and silently. CMake cannot tell a cache entry left at its default from one somebody passed, so a check that the two agree would either miss -DVITASDK_FLOAT_ABI=hard or refuse every re-configure of an existing build directory. Passing both is passing the same thing twice. The test runs stage 1 against a cmake that records its arguments, which is what the flag being parsed and dropped would have failed.
1 parent 906e51c commit e793cd9

4 files changed

Lines changed: 58 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,30 @@ set(target_arch arm-vita-eabi)
9999
set(VITASDK_FLOAT_ABI "hard" CACHE STRING
100100
"Float ABI baked into the toolchain: hard (default) or softfp")
101101
set_property(CACHE VITASDK_FLOAT_ABI PROPERTY STRINGS hard softfp)
102+
103+
# A profile names a world, and the world decides the ABI rather than the other
104+
# way round: CI asks for a profile because that is what the lock carries, and
105+
# describe already refuses one this repository does not publish.
106+
#
107+
# A profile wins over VITASDK_FLOAT_ABI, and does so silently. CMake cannot
108+
# tell a cache entry left at its default from one somebody passed, so a check
109+
# that the two agree would either miss -DVITASDK_FLOAT_ABI=hard or refuse
110+
# every re-configure of an existing build directory. Passing both is passing
111+
# the same thing twice; the profile is the one that says which world this is.
112+
include(Profiles)
113+
set(VITASDK_PROFILE "" CACHE STRING "World to build; selects the float ABI")
114+
if(VITASDK_PROFILE)
115+
if(NOT VITASDK_PROFILE IN_LIST VITASDK_PROFILES)
116+
message(FATAL_ERROR
117+
"unknown profile '${VITASDK_PROFILE}'; this tree publishes: ${VITASDK_PROFILES}")
118+
endif()
119+
set(profile_float_abi ${VITASDK_PROFILE_FLOAT_ABI_${VITASDK_PROFILE}})
120+
if(NOT profile_float_abi)
121+
message(FATAL_ERROR "profile '${VITASDK_PROFILE}' declares no float ABI")
122+
endif()
123+
set(VITASDK_FLOAT_ABI ${profile_float_abi} CACHE STRING "" FORCE)
124+
endif()
125+
102126
if(NOT VITASDK_FLOAT_ABI STREQUAL "hard" AND NOT VITASDK_FLOAT_ABI STREQUAL "softfp")
103127
message(FATAL_ERROR "VITASDK_FLOAT_ABI must be 'hard' or 'softfp', got '${VITASDK_FLOAT_ABI}'")
104128
endif()

cmake/Profiles.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ include_guard(GLOBAL)
22

33
# Published profile (world) names; describe rejects anything else.
44
set(VITASDK_PROFILES vita vita-softfp)
5+
6+
# The float ABI each profile bakes into the toolchain. A profile is a world and
7+
# a world is named by the architecture its packages carry, so the name is the
8+
# same on both sides of the build.
9+
set(VITASDK_PROFILE_FLOAT_ABI_vita hard)
10+
set(VITASDK_PROFILE_FLOAT_ABI_vita-softfp softfp)

scripts/ci/build-host.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ for required in host stage artifacts_dir out_dir build_id version revision profi
7171
exit 2
7272
}
7373
done
74-
# profile is required but not yet consumed: no profile -> VITASDK_FLOAT_ABI
75-
# mapping exists in CMakeLists.txt yet.
76-
: "$profile"
7774

7875
actual_revision=$(git -C "$repo_root" rev-parse HEAD)
7976
[[ $actual_revision == "$revision" ]] || {
@@ -175,6 +172,9 @@ build_and_stage() {
175172
local -a extra_args=("$@")
176173
local -a cmake_args=(
177174
-S "$repo_root" -B build ${extra_args[@]+"${extra_args[@]}"}
175+
# The lock says which world this is; the profile is how the tree is
176+
# told, and it is what decides the float ABI baked into the toolchain.
177+
-DVITASDK_PROFILE="$profile"
178178
-DVITASDK_SOURCE_REVISION="$revision"
179179
-DVITASDK_SOURCE_DATE_EPOCH="$source_date_epoch"
180180
# The lock names the host; artifacts published under any other name
@@ -363,6 +363,7 @@ if [[ $stage == 1 ]]; then
363363
enable_ccache
364364
cmake -S "$repo_root" -B build \
365365
-DVITASDK_TARGET_ONLY=ON \
366+
-DVITASDK_PROFILE="$profile" \
366367
-DVITASDK_SOURCE_REVISION="$revision" \
367368
-DVITASDK_SOURCE_DATE_EPOCH="$source_date_epoch"
368369
cmake --build build --target sysroot --parallel "$(ci_nproc)"

tests/ci/test-build-host-args.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,28 @@ grep -q 'curl disabled in test' <<< "$output" || {
124124
exit 1
125125
}
126126

127+
# 6. The profile reaches cmake. The lock is where CI says which world it is
128+
# building, and the profile is the only thing that carries it into the tree;
129+
# until this existed the flag was parsed, required, and then dropped, so a
130+
# softfp lock produced a hard-float toolchain that said nothing.
131+
recorded="$temporary_directory/cmake-args"
132+
cat > "$fake_bin/cmake" <<EOF
133+
#!/usr/bin/env bash
134+
printf '%s\n' "\$@" >> "$recorded"
135+
exit 0
136+
EOF
137+
chmod +x "$fake_bin/cmake"
138+
139+
run_build_host \
140+
--host x86_64-linux-gnu --stage 1 \
141+
--artifacts-dir "$temporary_directory/artifacts-6" --out-dir "$temporary_directory/out-6" \
142+
--build-id sha256:test --version 0.1.1 --revision "$revision" \
143+
--profile vita-softfp --packaged false >/dev/null 2>&1 || true
144+
145+
grep -qx -- '-DVITASDK_PROFILE=vita-softfp' "$recorded" || {
146+
printf 'stage 1 did not pass the profile to cmake:\n%s\n' "$(cat "$recorded")" >&2
147+
exit 1
148+
}
149+
rm -f "$fake_bin/cmake" "$recorded"
150+
127151
printf 'build-host.sh argument contract tests passed\n'

0 commit comments

Comments
 (0)