Skip to content

Commit ba3babf

Browse files
committed
Build the softfp shims with the compiler that exists
The shim command depended on gcc-base. The staged pipeline builds no such target -- it goes binutils and vita-headers, then newlib, then gcc-final -- so asking for the shims failed with No rule to make target 'gcc-base', needed by 'softfp-shim.stamp' and took the sysroot with it. The dependency has been dangling since this was rebased onto the staged pipeline; nothing reached the target until the export started waiting for it, so nothing said so. It now waits for gcc_final_barrier, which is a variable and not yet set where the command used to live, so the recipe moves to a file of its own included after BuildGccFinal. Stage 2 does not include it: it imports the archives already spliced and builds no components. The test checks the recipe names no compiler that is not built, that it waits for the one that is, and that it is included after it.
1 parent cd2db96 commit ba3babf

4 files changed

Lines changed: 60 additions & 24 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ if(NOT VITASDK_TARGET_ONLY)
302302
include(cmake/recipes/BuildHostTools.cmake)
303303
endif()
304304
include(cmake/recipes/BuildGccFinal.cmake)
305+
# After the compiler: the wrappers are assembled with it. Stage 2 imports the
306+
# archives already spliced and builds no components, so there is nothing to
307+
# splice there.
308+
if(NOT VITASDK_STAGE1_DIR)
309+
include(cmake/recipes/SoftfpShims.cmake)
310+
endif()
305311
include(cmake/recipes/Provenance.cmake)
306312

307313
# What the target half is made of, named once because two things wait for it:

cmake/recipes/BuildSdkComponents.cmake

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,6 @@ ExternalProject_add(vita-headers
2525
${UPDATE_DISCONNECTED_SUPPORT}
2626
)
2727

28-
# The softfp world calls the same hard-float Sce* stubs vita-headers just
29-
# installed, but with float/double arguments and return values sitting in
30-
# the wrong registers (AAPCS-base vs AAPCS-VFP). Splice the 23 shims from
31-
# softfp-shim/ into the affected stub archives in place -- see
32-
# PLAN-softfp.md, "Fase 1 - los 23 shims de serie" and
33-
# scripts/patch-softfp-stub-archives.sh for why this is an archive rewrite
34-
# and not a -lvita_softfp_shim added to LIB_SPEC.
35-
if(VITASDK_FLOAT_ABI STREQUAL "softfp")
36-
add_custom_command(
37-
OUTPUT ${CMAKE_BINARY_DIR}/softfp-shim.stamp
38-
COMMAND ${PROJECT_SOURCE_DIR}/scripts/build-softfp-shim.sh
39-
${binutils_prefix}-gcc ${binutils_prefix}-ar ${binutils_prefix}-objcopy
40-
${PROJECT_SOURCE_DIR}/softfp-shim
41-
${CMAKE_INSTALL_PREFIX}/${target_arch}/include
42-
${CMAKE_INSTALL_PREFIX}/${target_arch}/lib
43-
${toolchain_build_install_dir}/${target_arch}/lib
44-
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/softfp-shim.stamp
45-
DEPENDS vita-headers gcc-base binutils_${build_suffix}
46-
COMMENT "Splicing the softfp ABI shims into the stub archives"
47-
VERBATIM
48-
)
49-
add_custom_target(softfp-shim ALL DEPENDS ${CMAKE_BINARY_DIR}/softfp-shim.stamp)
50-
endif()
51-
5228
ExternalProject_Add(newlib
5329
DEPENDS binutils_${target_suffix} vita-headers
5430
GIT_REPOSITORY ${NEWLIB_REPOSITORY}

cmake/recipes/SoftfpShims.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright(c) 2016 codestation
3+
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
4+
#
5+
6+
# The softfp world calls the same hard-float Sce* stubs vita-headers just
7+
# installed, but with float/double arguments and return values sitting in the
8+
# wrong registers (AAPCS-base vs AAPCS-VFP). Splice the 23 shims from
9+
# softfp-shim/ into the affected stub archives in place -- see PLAN-softfp.md,
10+
# "Fase 1 - los 23 shims de serie" and scripts/patch-softfp-stub-archives.sh
11+
# for why this is an archive rewrite and not a -lvita_softfp_shim added to
12+
# LIB_SPEC.
13+
#
14+
# Its own file because it has to be included after the compiler that
15+
# assembles the wrappers exists. It used to depend on the base compiler the
16+
# staged pipeline stopped building, and the dangling name went unnoticed until
17+
# the target was first asked for.
18+
19+
include_guard(GLOBAL)
20+
21+
if(VITASDK_FLOAT_ABI STREQUAL "softfp")
22+
add_custom_command(
23+
OUTPUT ${CMAKE_BINARY_DIR}/softfp-shim.stamp
24+
COMMAND ${PROJECT_SOURCE_DIR}/scripts/build-softfp-shim.sh
25+
${binutils_prefix}-gcc ${binutils_prefix}-ar ${binutils_prefix}-objcopy
26+
${PROJECT_SOURCE_DIR}/softfp-shim
27+
${CMAKE_INSTALL_PREFIX}/${target_arch}/include
28+
${CMAKE_INSTALL_PREFIX}/${target_arch}/lib
29+
${toolchain_build_install_dir}/${target_arch}/lib
30+
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/softfp-shim.stamp
31+
DEPENDS vita-headers ${gcc_final_barrier} binutils_${build_suffix}
32+
COMMENT "Splicing the softfp ABI shims into the stub archives"
33+
VERBATIM
34+
)
35+
add_custom_target(softfp-shim DEPENDS ${CMAKE_BINARY_DIR}/softfp-shim.stamp)
36+
endif()

tests/cmake/target-half-dependencies.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ expect_absent("cmake/recipes/ExportSysroot.cmake" "softfp-shim"
4444
expect_absent("cmake/recipes/FinalizeSdk.cmake" "softfp-shim"
4545
"FinalizeSdk.cmake names softfp-shim itself instead of taking the list")
4646

47+
# The wrappers are assembled with the target compiler, so the recipe has to be
48+
# included after whatever builds it. It named gcc-base, which the staged
49+
# pipeline stopped building, and the dangling dependency went unnoticed until
50+
# the target was first asked for -- make reported "No rule to make target
51+
# 'gcc-base'" and took the whole sysroot with it.
52+
expect_absent("cmake/recipes/SoftfpShims.cmake" "gcc-base"
53+
"the shim recipe still names gcc-base, which nothing builds")
54+
expect_contains("cmake/recipes/SoftfpShims.cmake" "\${gcc_final_barrier}"
55+
"the shim recipe does not wait for the compiler that assembles it")
56+
57+
file(READ "${repository_root}/CMakeLists.txt" cmakelists)
58+
string(FIND "${cmakelists}" "include(cmake/recipes/BuildGccFinal.cmake)" gcc_at)
59+
string(FIND "${cmakelists}" "include(cmake/recipes/SoftfpShims.cmake)" shim_at)
60+
if(shim_at LESS gcc_at)
61+
message(SEND_ERROR
62+
"FAIL: the shim recipe is included before the compiler it needs")
63+
endif()
64+
4765
# A softfp world whose shims were never spliced is a toolchain that
4866
# miscompiles quietly, so the list carries them exactly when the world is one.
4967
expect_contains("CMakeLists.txt"

0 commit comments

Comments
 (0)