From 675a4622b03fc85d4b48cde3023aa27f4bb4836a Mon Sep 17 00:00:00 2001 From: Jeremy Prater Date: Mon, 23 Jun 2025 13:09:03 -0700 Subject: [PATCH 01/41] Add cmake 3.22.3 to recipes-devtools to fix dunfell compile --- recipes-devtools/cmake/cmake-native_3.22.3.bb | 65 +++++++++++++++ recipes-devtools/cmake/cmake.inc | 31 ++++++++ ...mpilerABI-Strip-pipe-from-compile-fl.patch | 52 ++++++++++++ ...stem-use-oe-environment-vars-to-load.patch | 44 +++++++++++ ...t-OpenEmbedded-Qt4-tool-binary-names.patch | 56 +++++++++++++ ...-if-system-Qt-installation-is-broken.patch | 79 +++++++++++++++++++ ...xt2fs-ext2_fs.h-by-cmake-s-internal-.patch | 39 +++++++++ .../cmake/cmake/OEToolchainConfig.cmake | 23 ++++++ .../cmake/SDKToolchainConfig.cmake.template | 31 ++++++++ recipes-devtools/cmake/cmake/cmake-setup.py | 33 ++++++++ .../cmake/cmake/environment.d-cmake.sh | 2 + recipes-devtools/cmake/cmake_3.22.3.bb | 67 ++++++++++++++++ 12 files changed, 522 insertions(+) create mode 100644 recipes-devtools/cmake/cmake-native_3.22.3.bb create mode 100644 recipes-devtools/cmake/cmake.inc create mode 100644 recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch create mode 100644 recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch create mode 100644 recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch create mode 100644 recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch create mode 100644 recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch create mode 100644 recipes-devtools/cmake/cmake/OEToolchainConfig.cmake create mode 100644 recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template create mode 100755 recipes-devtools/cmake/cmake/cmake-setup.py create mode 100644 recipes-devtools/cmake/cmake/environment.d-cmake.sh create mode 100644 recipes-devtools/cmake/cmake_3.22.3.bb diff --git a/recipes-devtools/cmake/cmake-native_3.22.3.bb b/recipes-devtools/cmake/cmake-native_3.22.3.bb new file mode 100644 index 0000000..45ea78a --- /dev/null +++ b/recipes-devtools/cmake/cmake-native_3.22.3.bb @@ -0,0 +1,65 @@ +require cmake.inc +inherit native + +DEPENDS += "bzip2-replacement-native xz-native zlib-native curl-native ncurses-native zstd-native" + +SRC_URI += "file://OEToolchainConfig.cmake \ + file://environment.d-cmake.sh \ + file://0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch \ + file://0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch \ + " + +LICENSE:append = " & BSD-1-Clause & MIT & BSD-2-Clause" +LIC_FILES_CHKSUM:append = " \ + file://Utilities/cmjsoncpp/LICENSE;md5=fa2a23dd1dc6c139f35105379d76df2b \ + file://Utilities/cmlibarchive/COPYING;md5=d499814247adaee08d88080841cb5665 \ + file://Utilities/cmexpat/COPYING;md5=9e2ce3b3c4c0f2670883a23bbd7c37a9 \ + file://Utilities/cmlibrhash/COPYING;md5=a8c2a557a5c53b1c12cddbee98c099af \ + file://Utilities/cmlibuv/LICENSE;md5=a68902a430e32200263d182d44924d47 \ +" + +B = "${WORKDIR}/build" +do_configure[cleandirs] = "${B}" + +CMAKE_EXTRACONF = "\ + -DCMAKE_LIBRARY_PATH=${STAGING_LIBDIR_NATIVE} \ + -DBUILD_CursesDialog=1 \ + -DCMAKE_USE_SYSTEM_LIBRARIES=1 \ + -DCMAKE_USE_SYSTEM_LIBRARY_JSONCPP=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_LIBRHASH=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_EXPAT=0 \ + -DENABLE_ACL=0 -DHAVE_ACL_LIBACL_H=0 \ + -DHAVE_SYS_ACL_H=0 \ + -DCURL_LIBRARIES=-lcurl \ +" + +do_configure () { + ${S}/configure --verbose --prefix=${prefix} \ + ${@oe.utils.parallel_make_argument(d, '--parallel=%d')} \ + ${@bb.utils.contains('CCACHE', 'ccache ', '--enable-ccache', '', d)} \ + -- ${CMAKE_EXTRACONF} +} + +do_compile() { + oe_runmake +} + +do_install() { + oe_runmake 'DESTDIR=${D}' install + + # The following codes are here because eSDK needs to provide compatibilty + # for SDK. That is, eSDK could also be used like traditional SDK. + mkdir -p ${D}${datadir}/cmake + install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/ + mkdir -p ${D}${base_prefix}/environment-setup.d + install -m 644 ${WORKDIR}/environment.d-cmake.sh ${D}${base_prefix}/environment-setup.d/cmake.sh + + # Help docs create tons of files in the native sysroot and aren't needed there + rm -rf ${D}${datadir}/cmake-*/Help +} + +do_compile[progress] = "percent" + +SYSROOT_DIRS_NATIVE += "${datadir}/cmake ${base_prefix}/environment-setup.d" diff --git a/recipes-devtools/cmake/cmake.inc b/recipes-devtools/cmake/cmake.inc new file mode 100644 index 0000000..3811aae --- /dev/null +++ b/recipes-devtools/cmake/cmake.inc @@ -0,0 +1,31 @@ +# Copyright (C) 2005, Koninklijke Philips Electronics NV. All Rights Reserved +# Released under the MIT license (see packages/COPYING) + +SUMMARY = "Cross-platform, open-source make system" +DESCRIPTION = "CMake is used to control the software compilation process \ +using simple platform and compiler independent configuration files. CMake \ +generates native makefiles and workspaces that can be used in the compiler \ +environment of your choice." +HOMEPAGE = "http://www.cmake.org/" +BUGTRACKER = "http://public.kitware.com/Bug/my_view_page.php" +SECTION = "console/utils" +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://Copyright.txt;md5=31023e1d3f51ca90a58f55bcee8e2339 \ + file://Source/cmake.h;beginline=1;endline=2;md5=a5f70e1fef8614734eae0d62b4f5891b \ + " + +CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" + +SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \ + file://0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch \ + file://0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch \ + file://0004-Fail-silently-if-system-Qt-installation-is-broken.patch \ +" + +SRC_URI[sha256sum] = "9f8469166f94553b6978a16ee29227ec49a2eb5ceb608275dec40d8ae0d1b5a0" + +UPSTREAM_CHECK_REGEX = "cmake-(?P\d+(\.\d+)+)\.tar" + +# This is specific to the npm package that installs cmake, so isn't +# relevant to OpenEmbedded +CVE_CHECK_IGNORE += "CVE-2016-10642" diff --git a/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch b/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch new file mode 100644 index 0000000..a302734 --- /dev/null +++ b/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch @@ -0,0 +1,52 @@ +From dab7ba34f87be0172f6586325656ee962de0029e Mon Sep 17 00:00:00 2001 +From: Philip Lorenz +Date: Mon, 3 Jun 2024 13:19:24 +0200 +Subject: [PATCH] CMakeDetermineCompilerABI: Strip -pipe from compile flags + +When `-pipe` is enabled, GCC passes data between its different +executables using pipes instead of temporary files. This leads to issues +when cmake attempts to infer compiler internals via the `-v` parameter +as each executable will print to `stderr` in parallel. + +For example we have observed the following outputs in our builds which +sporadically lead to build failures as system include directories were +not detected reliably: + +Parsed CXX implicit include dir info from above output: rv=done + found start of include info + found start of implicit include info + add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include] + add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include-fixed] + add: [.../usr/include/c++/11.4.0] + add: [.../usr/include/c++/11.4.0/x86_64-poky-linux] + add: [.../usr/include/c++/11.4.0/backward] + add: [.../usr/lib/x86_64-poky-linux/11.4.0/include] + add: [...GNU assembler version 2.38 (x86_64-poky-linux) using BFD version (GNU Binutils) 2.38.20220708] + add: [/usr/include] + end of search list found + +Fix this issue by stripping the `-pipe` parameter from the compilation +flag when determining the toolchain configuration. + +Upstream-Status: Backport [3.32.0, 71be059f3f32b6791427893a48ba4815a19e2e78] +Signed-off-by: Philip Lorenz +--- + Modules/CMakeDetermineCompilerABI.cmake | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake +index 8191d819bf..ae4c9ee44e 100644 +--- a/Modules/CMakeDetermineCompilerABI.cmake ++++ b/Modules/CMakeDetermineCompilerABI.cmake +@@ -35,6 +35,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) + + # Avoid failing ABI detection on warnings. + string(REGEX REPLACE "(^| )-Werror([= ][^ ]*)?( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") ++ # Avoid passing of "-pipe" when determining the compiler internals. With ++ # "-pipe" GCC will use pipes to pass data between the involved ++ # executables. This may lead to issues when their stderr output (which ++ # contains the relevant compiler internals) becomes interweaved. ++ string(REGEX REPLACE "(^| )-pipe( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") + + # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables + # and set them to "C" that way GCC's "search starts here" text is in diff --git a/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch b/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch new file mode 100644 index 0000000..9a2287f --- /dev/null +++ b/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch @@ -0,0 +1,44 @@ +From 89f6c846f02ad6d30b9ebb7eaaaa4fb6f9cec054 Mon Sep 17 00:00:00 2001 +From: Cody P Schafer +Date: Thu, 27 Apr 2017 11:35:05 -0400 +Subject: [PATCH] CMakeDetermineSystem: use oe environment vars to load default + toolchain file in sdk + +Passing the toolchain by: + + - shell aliases does not work if cmake is called by a script + - unconditionally by a wrapper script causes cmake to believe it is + configuring things when it is not (for example, `cmake --build` breaks). + +The OE_CMAKE_TOOLCHAIN_FILE variable is only used as a default if no +toolchain is explicitly specified. + +Setting the CMAKE_TOOLCHAIN_FILE cmake variable is marked as cached +because '-D' options are cache entries themselves. + +Upstream-Status: Inappropriate [oe-core specific] +Signed-off-by: Cody P Schafer +Signed-off-by: Otavio Salvador + +--- + Modules/CMakeDetermineSystem.cmake | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake +index 8c7af067..ade2b189 100644 +--- a/Modules/CMakeDetermineSystem.cmake ++++ b/Modules/CMakeDetermineSystem.cmake +@@ -112,6 +112,13 @@ else() + endif() + endif() + ++if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) ++ if(DEFINED ENV{OE_CMAKE_TOOLCHAIN_FILE}) ++ set(CMAKE_TOOLCHAIN_FILE "$ENV{OE_CMAKE_TOOLCHAIN_FILE}" CACHE FILEPATH "toolchain file") ++ message(STATUS "Toolchain file defaulted to '${CMAKE_TOOLCHAIN_FILE}'") ++ endif() ++endif() ++ + # if a toolchain file is used, the user wants to cross compile. + # in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_* + # variables around so they can be used in CMakeLists.txt. diff --git a/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch b/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch new file mode 100644 index 0000000..575a5cb --- /dev/null +++ b/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch @@ -0,0 +1,56 @@ +From 2d02ac91d5a5d72eaddba4894eaa6db3ed8fee62 Mon Sep 17 00:00:00 2001 +From: Otavio Salvador +Date: Thu, 12 May 2011 15:36:03 +0000 +Subject: [PATCH] cmake: support OpenEmbedded Qt4 tool binary names + +The FindQt4 module looks for Qt4 binaries to be able to gather the +paths used for compilation and also to be using during other processes +(translation update, translation binary generating and like) however +OpenEmbedded has renamed those to allow old QMake to be used in +parallel with the current one. This patch adds support for the +OpenEmbedded specific binary names. + +Upstream-Status: Inappropriate [embedded specific] + +Signed-off-by: Otavio Salvador + +The patch was slightly adapted in order to match cmake 3.2.2: +Instead of find_program, _find_qt4_program is now used. + +Signed-off-by: Moritz Blume +Signed-off-by: Otavio Salvador + +--- + Modules/FindQt4.cmake | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake +index 3993968..b2a8585 100644 +--- a/Modules/FindQt4.cmake ++++ b/Modules/FindQt4.cmake +@@ -518,7 +518,7 @@ endfunction() + + set(QT4_INSTALLED_VERSION_TOO_OLD FALSE) + +-set(_QT4_QMAKE_NAMES qmake qmake4 qmake-qt4 qmake-mac) ++set(_QT4_QMAKE_NAMES qmake qmake2 qmake4 qmake-qt4 qmake-mac) + _qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION) + + if (QT_QMAKE_EXECUTABLE AND +@@ -1136,12 +1136,12 @@ if (QT_QMAKE_EXECUTABLE AND + _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc4 moc) + _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic4 uic) + _find_qt4_program(QT_UIC3_EXECUTABLE Qt4::uic3 uic3) +- _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc) +- _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml) +- _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp) ++ _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc4 rcc) ++ _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml4 qdbuscpp2xml) ++ _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp4 qdbusxml2cpp) + _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate4 lupdate) + _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease4 lrelease) +- _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator) ++ _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator qcollectiongenerator4) + _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer4 designer) + _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist4 linguist) + diff --git a/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch b/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch new file mode 100644 index 0000000..1b196db --- /dev/null +++ b/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch @@ -0,0 +1,79 @@ +From 60864efbe52cc12018efaafbc4e4c3c8b4af2b65 Mon Sep 17 00:00:00 2001 +From: Otavio Salvador +Date: Thu, 5 Jul 2018 10:26:48 -0300 +Subject: [PATCH] Fail silently if system Qt installation is broken + +Fixes a regression in behaviour from 2.8.10 to 2.8.11 resulting in the +following error if the system Qt installation is broken: + +CMake Error at Modules/FindQt4.cmake:1028 (set_property): + set_property could not find TARGET Qt4::QtCore. Perhaps it has not yet + been created. +Call Stack (most recent call first): + Tests/RunCMake/CMakeLists.txt:79 (find_package) + +Upstream-Status: Pending + +Signed-off-by: Paul Eggleton + +The patch was slightly adapted in order to match cmake 3.2.2: +Another set_property was introduced which had to be included +within the if(QT_QTCORE_FOUND) statement. + +Signed-off-by: Moritz Blume +Signed-off-by: Otavio Salvador + +--- + Modules/FindQt4.cmake | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake +index b2a8585..77c89aa 100644 +--- a/Modules/FindQt4.cmake ++++ b/Modules/FindQt4.cmake +@@ -988,25 +988,26 @@ if (QT_QMAKE_EXECUTABLE AND + endif() + endmacro() + +- +- # Set QT_xyz_LIBRARY variable and add +- # library include path to QT_INCLUDES +- _QT4_ADJUST_LIB_VARS(QtCore) +- set_property(TARGET Qt4::QtCore APPEND PROPERTY +- INTERFACE_INCLUDE_DIRECTORIES +- "${QT_MKSPECS_DIR}/default" +- ${QT_INCLUDE_DIR} +- ) +- set_property(TARGET Qt4::QtCore APPEND PROPERTY +- INTERFACE_COMPILE_DEFINITIONS +- $<$>:QT_NO_DEBUG> +- ) +- set_property(TARGET Qt4::QtCore PROPERTY +- INTERFACE_QT_MAJOR_VERSION 4 +- ) +- set_property(TARGET Qt4::QtCore APPEND PROPERTY +- COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION +- ) ++ if(QT_QTCORE_FOUND) ++ # Set QT_xyz_LIBRARY variable and add ++ # library include path to QT_INCLUDES ++ _QT4_ADJUST_LIB_VARS(QtCore) ++ set_property(TARGET Qt4::QtCore APPEND PROPERTY ++ INTERFACE_INCLUDE_DIRECTORIES ++ "${QT_MKSPECS_DIR}/default" ++ ${QT_INCLUDE_DIR} ++ ) ++ set_property(TARGET Qt4::QtCore APPEND PROPERTY ++ INTERFACE_COMPILE_DEFINITIONS ++ $<$>:QT_NO_DEBUG> ++ ) ++ set_property(TARGET Qt4::QtCore PROPERTY ++ INTERFACE_QT_MAJOR_VERSION 4 ++ ) ++ set_property(TARGET Qt4::QtCore APPEND PROPERTY ++ COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION ++ ) ++ endif() + + foreach(QT_MODULE ${QT_MODULES}) + _QT4_ADJUST_LIB_VARS(${QT_MODULE}) diff --git a/recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch b/recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch new file mode 100644 index 0000000..d6f7308 --- /dev/null +++ b/recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch @@ -0,0 +1,39 @@ +From fd9a04c1434e12f21c043385e306e0b52d38d749 Mon Sep 17 00:00:00 2001 +From: Otavio Salvador +Date: Thu, 5 Jul 2018 10:28:04 -0300 +Subject: [PATCH] Disable use of ext2fs/ext2_fs.h by cmake's internal + + libarchive copy +Organization: O.S. Systems Software LTDA. + +We don't want to add a dependency on e2fsprogs-native for cmake-native, +and we don't use CPack so just disable this functionality. + +Upstream-Status: Inappropriate [config] + +Signed-off-by: Paul Eggleton +Signed-off-by: Otavio Salvador + +--- + Utilities/cmlibarchive/CMakeLists.txt | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt +index bfcaf30..2960683 100644 +--- a/Utilities/cmlibarchive/CMakeLists.txt ++++ b/Utilities/cmlibarchive/CMakeLists.txt +@@ -682,12 +682,8 @@ LA_CHECK_INCLUDE_FILE("copyfile.h" HAVE_COPYFILE_H) + LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H) + LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H) + LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H) +-LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H) +- +-CHECK_C_SOURCE_COMPILES("#include +-#include +-int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS) +- ++SET(HAVE_EXT2FS_EXT2_FS_H 0) ++SET(HAVE_WORKING_EXT2_IOC_GETFLAGS 0) + LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H) + LA_CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H) + LA_CHECK_INCLUDE_FILE("io.h" HAVE_IO_H) diff --git a/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake b/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake new file mode 100644 index 0000000..6434b27 --- /dev/null +++ b/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake @@ -0,0 +1,23 @@ +set( CMAKE_SYSTEM_NAME Linux ) +set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) +set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE ) +set( CMAKE_SYSROOT $ENV{OECORE_TARGET_SYSROOT} ) + +set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} ) +set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY ) + +set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "$ENV{OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX}") + +set( CMAKE_SYSTEM_PROCESSOR $ENV{OECORE_TARGET_ARCH} ) + +# Include the toolchain configuration subscripts +file( GLOB toolchain_config_files "${CMAKE_CURRENT_LIST_FILE}.d/*.cmake" ) +foreach(config ${toolchain_config_files}) + include(${config}) +endforeach() + +unset(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES) +unset(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES) diff --git a/recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template b/recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template new file mode 100644 index 0000000..c69569a --- /dev/null +++ b/recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template @@ -0,0 +1,31 @@ +set(SDK_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..") +set(HOST_SYSROOT "${SDK_INSTALL_DIR}/sysroots/@OECORE_SDK_SYS") +set(TARGET_SYSROOT "${SDK_INSTALL_DIR}/sysroots/@OECORE_TARGET_SYS") +set(HOST_BIN "${HOST_SYSROOT}/usr/bin") +set(TOOLCHAIN_NAME "@OECORE_TARGET_ALIAS") +set(GCC_DIR "${HOST_BIN}/${TOOLCHAIN_NAME}") + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR "@OECORE_TARGET_ARCH") + +set(CMAKE_C_COMPILER "${GCC_DIR}/${TOOLCHAIN_NAME}-gcc") +set(CMAKE_CXX_COMPILER "${GCC_DIR}/${TOOLCHAIN_NAME}-g++") + +set(ARCH_FLAGS "@OECORE_TUNE_CCARGS") +set(CMAKE_C_FLAGS "${ARCH_FLAGS}" CACHE STRING "" FORCE ) +set(CMAKE_CXX_FLAGS "${ARCH_FLAGS}" CACHE STRING "" FORCE ) +set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE ) +set(CMAKE_LDFLAGS_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE ) + +set(CMAKE_SYSROOT "${TARGET_SYSROOT}") + +set(CMAKE_FIND_ROOT_PATH "${TARGET_SYSROOT}" ) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY ) + +set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "") + +set(CMAKE_PROGRAM_PATH "${HOST_SYSROOT}/usr/bin" CACHE STRING "" FORCE) diff --git a/recipes-devtools/cmake/cmake/cmake-setup.py b/recipes-devtools/cmake/cmake/cmake-setup.py new file mode 100755 index 0000000..af587a4 --- /dev/null +++ b/recipes-devtools/cmake/cmake/cmake-setup.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import os +import string +import sys + +class Template(string.Template): + delimiter = "@" + +class Environ(): + def __getitem__(self, name): + if name == "OECORE_SDK_SYS": + return os.path.basename(os.environ["OECORE_NATIVE_SYSROOT"]) + elif name == "OECORE_TARGET_SYS": + return os.path.basename(os.environ["OECORE_TARGET_SYSROOT"]) + elif name == "OECORE_TARGET_ALIAS": + return os.path.basename(os.environ["TARGET_PREFIX"].strip("-")) + else: + return os.environ[name] + +try: + sysroot = os.environ['OECORE_NATIVE_SYSROOT'] +except KeyError: + print("Not in environment setup, bailing") + sys.exit(1) + +template_file = os.path.join(sysroot, 'usr/share/cmake/SDKToolchainConfig.cmake.template') +cross_file = os.path.join(sysroot, 'usr/share/cmake/%s-toolchain.cmake' % (os.path.basename(os.environ["OECORE_TARGET_SYSROOT"]))) +with open(template_file) as in_file: + template = in_file.read() + output = Template(template).substitute(Environ()) + with open(cross_file, "w") as out_file: + out_file.write(output) diff --git a/recipes-devtools/cmake/cmake/environment.d-cmake.sh b/recipes-devtools/cmake/cmake/environment.d-cmake.sh new file mode 100644 index 0000000..7bdb19f --- /dev/null +++ b/recipes-devtools/cmake/cmake/environment.d-cmake.sh @@ -0,0 +1,2 @@ +export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" +export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`" diff --git a/recipes-devtools/cmake/cmake_3.22.3.bb b/recipes-devtools/cmake/cmake_3.22.3.bb new file mode 100644 index 0000000..752c37b --- /dev/null +++ b/recipes-devtools/cmake/cmake_3.22.3.bb @@ -0,0 +1,67 @@ +require cmake.inc + +inherit cmake bash-completion + +DEPENDS += "curl expat zlib libarchive xz ncurses bzip2" + +SRC_URI:append:class-nativesdk = " \ + file://OEToolchainConfig.cmake \ + file://SDKToolchainConfig.cmake.template \ + file://cmake-setup.py \ + file://environment.d-cmake.sh \ + file://0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch \ +" + +LICENSE:append = " & BSD-1-Clause & MIT" +LIC_FILES_CHKSUM:append = " \ + file://Utilities/cmjsoncpp/LICENSE;md5=fa2a23dd1dc6c139f35105379d76df2b \ + file://Utilities/cmlibrhash/COPYING;md5=a8c2a557a5c53b1c12cddbee98c099af \ + file://Utilities/cmlibuv/LICENSE;md5=a68902a430e32200263d182d44924d47 \ +" + +# Strip ${prefix} from ${docdir}, set result into docdir_stripped +python () { + prefix=d.getVar("prefix") + docdir=d.getVar("docdir") + + if not docdir.startswith(prefix): + bb.fatal('docdir must contain prefix as its prefix') + + docdir_stripped = docdir[len(prefix):] + if len(docdir_stripped) > 0 and docdir_stripped[0] == '/': + docdir_stripped = docdir_stripped[1:] + + d.setVar("docdir_stripped", docdir_stripped) +} + +EXTRA_OECMAKE=" \ + -DCMAKE_DOC_DIR=${docdir_stripped}/cmake-${CMAKE_MAJOR_VERSION} \ + -DCMAKE_USE_SYSTEM_LIBRARIES=1 \ + -DCMAKE_USE_SYSTEM_LIBRARY_JSONCPP=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_LIBRHASH=0 \ + -DKWSYS_CHAR_IS_SIGNED=1 \ + -DBUILD_CursesDialog=0 \ + -DKWSYS_LFS_WORKS=1 \ +" + +do_install:append:class-nativesdk() { + mkdir -p ${D}${datadir}/cmake + install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/ + + mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d + install -m 644 ${WORKDIR}/environment.d-cmake.sh ${D}${SDKPATHNATIVE}/environment-setup.d/cmake.sh + + # install cmake-setup.py to create arch-specific toolchain cmake file from template + install -m 0644 ${WORKDIR}/SDKToolchainConfig.cmake.template ${D}${datadir}/cmake/ + install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d + install -m 0755 ${WORKDIR}/cmake-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/ +} + +FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}" + +FILES:${PN} += "${datadir}/cmake-${CMAKE_MAJOR_VERSION} ${datadir}/cmake ${datadir}/aclocal ${datadir}/emacs ${datadir}/vim" +FILES:${PN}-doc += "${docdir}/cmake-${CMAKE_MAJOR_VERSION}" +FILES:${PN}-dev = "" + +BBCLASSEXTEND = "nativesdk" From f558eab75de3f44b5c012c60487da7279de6ca65 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:42:26 +1000 Subject: [PATCH 02/41] update layer compat from Dunfell to Scarthgap Scarthgap uses a different syntax for adding append and prepend rules; update recipe syntax for this, along with updating LAYERSERIES_COMPAT to scarthgap. Dunfell compatibility can be re-added at a later date should it be required. --- classes/swift-cmake-base.bbclass | 35 +++++++++++++++++++------------- classes/swift-cmake.bbclass | 2 +- conf/layer.conf | 2 +- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 1b59da2..6e28cb1 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -2,25 +2,27 @@ inherit cmake DEPENDS_append += " swift-native libgcc gcc glibc " +DEPENDS:append = " swift-native libgcc gcc glibc " + SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aarch64', d)}" SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', 'aarch64', d)}" -HOST_CC_ARCH_prepend = "-target ${SWIFT_TARGET_NAME}" +HOST_CC_ARCH:prepend = "-target ${SWIFT_TARGET_NAME} " ################################################################################ # NOTE: The host running bitbake must have lld available and the following # # must be added to the local.conf file: # # # -# HOSTTOOLS += "ld.lld" # +# HOSTTOOLS:append = " ld.lld" # # # ################################################################################ # Use lld (see note above) -TARGET_LDFLAGS += "-fuse-ld=lld" +TARGET_LDFLAGS:append = " -fuse-ld=lld" # Add build-id to generated binaries -TARGET_LDFLAGS += "-Xlinker --build-id=sha1" +TARGET_LDFLAGS:append = " -Xlinker --build-id=sha1" # Use Apple's provided clang (it understands Apple's custom compiler flags) # Made available via swift-native package. @@ -31,10 +33,14 @@ OECMAKE_CXX_COMPILER = "clang++" RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" TARGET_LDFLAGS += "-w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" -EXTRA_INCLUDE_FLAGS ?= "" -OECMAKE_C_FLAGS += "${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -OECMAKE_CXX_FLAGS += "${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -OECMAKE_ASM_FLAGS += "${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" +OECMAKE_C_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" +OECMAKE_CXX_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" +OECMAKE_ASM_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" + +SWIFTC_BIN = "${STAGING_DIR_NATIVE}/usr/bin/swiftc" + +EXTRA_OECMAKE:append = " -DCMAKE_Swift_COMPILER=${SWIFTC_BIN}" +EXTRA_OECMAKE:append = " -DCMAKE_SWIFT_COMPILER=${SWIFTC_BIN}" BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" @@ -58,12 +64,7 @@ SWIFT_FLAGS = "-target ${SWIFT_TARGET_NAME} -use-ld=lld \ ${EXTRA_SWIFTC_FLAGS} \ " -HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/opt/usr/lib/llvm-swift" -EXTRA_OECMAKE += '-DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' -EXTRA_OECMAKE += " -DSWIFT_USE_LINKER=lld" -EXTRA_OECMAKE += " -DLLVM_USE_LINKER=lld" -EXTRA_OECMAKE += " -DLLVM_DIR=${HOST_LLVM_PATH}/lib/cmake/llvm" -EXTRA_OECMAKE += " -DLLVM_BUILD_LIBRARY_DIR=${HOST_LLVM_PATH}" +HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/usr/lib" EXTRANATIVEPATH += "swift-tools" @@ -104,4 +105,10 @@ do_create_gcc_version_symlinks() { } addtask do_create_gcc_version_symlinks after do_prepare_recipe_sysroot before do_configure +EXTRA_OECMAKE:append = ' -DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' +EXTRA_OECMAKE:append = " -DSWIFT_USE_LINKER=lld" +EXTRA_OECMAKE:append = " -DLLVM_USE_LINKER=lld" +EXTRA_OECMAKE:append = " -DLLVM_DIR=${HOST_LLVM_PATH}/cmake/llvm" +EXTRA_OECMAKE:append = " -DLLVM_BUILD_LIBRARY_DIR=${HOST_LLVM_PATH}" +EXTRANATIVEPATH:append = " swift-tools" diff --git a/classes/swift-cmake.bbclass b/classes/swift-cmake.bbclass index 211c33d..79f0643 100644 --- a/classes/swift-cmake.bbclass +++ b/classes/swift-cmake.bbclass @@ -1,5 +1,5 @@ inherit swift-cmake-base -DEPENDS_append += " swift-stdlib libdispatch libfoundation " +DEPENDS:append = "swift-stdlib libdispatch swift-foundation" TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" diff --git a/conf/layer.conf b/conf/layer.conf index afa9241..0273513 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -9,4 +9,4 @@ BBFILE_COLLECTIONS += "swift-layer" BBFILE_PATTERN_swift-layer := "^${LAYERDIR}/" BBFILE_PRIORITY_swift-layer = "7" -LAYERSERIES_COMPAT_swift-layer = "dunfell" +LAYERSERIES_COMPAT_swift-layer = "scarthgap" From 3a3042121912c9c8c2e012c83ad2dfa234fd8585 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:20:01 +1000 Subject: [PATCH 03/41] update README.md for style and to avoid Swift version dependencies Do not specifically refer to Swift 5.7.1 in README.md, to avoid having to update it on every minor Swift update. Some small stylistic and syntactic changes. --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 76a3c1f..3a1c57c 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # meta-swift -Yocto meta-layer for swift-on-arm (Swift 5.7.1) + +Yocto layer for the Swift programming language. # Usage -Add this meta layer to your project (refer to yocto user manual) +Add this layer to your project (refer to Yocto user manual, or use `bitbake-layers add-layer`). -Create a new swift application and include it in your yocto build as follows... +Create a new Swift application and include it in your build as follows: ``` -DESCRIPTION = "My swift 5.7.1 app" +DESCRIPTION = "My Swift app" LICENSE = "CLOSED" SRC_URI = "file://Sources/hello-world/main.swift \ @@ -18,14 +19,14 @@ SRC_URI = "file://Sources/hello-world/main.swift \ inherit swift ``` -This does a few things, when you `inherit swift` meta-layer class, it will does the following... +When you `inherit swift` class, it does the following: -- Automatically download the x86_64 and ARMv7 swift 5.7.1 binaries and create a cross-compiling sys-root -- Add an RDEPENDS_${PN} for `swift` which is the Armv7 runtime +- Automatically download the x86\_64 SDK binaries and create a cross-compiling sysroot +- Add an RDEPENDS:${PN} for `swift` - Performs the required build steps # Deployment -The user of this meta-layer must provide their own `do_install` function. +The user of this layer must provide their own `do_install` function. -The finished binaries are located in ${WORKDIR}/.build/release/* \ No newline at end of file +The finished binaries are located in ${BUILD\_DIR}. From 900e4cdc0383b5bf59d140610c493ca6a61bcb25 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:20:44 +1000 Subject: [PATCH 04/41] remove build.sh; this does not belong in a Yocto layer Remove the build.sh script; building and testing infrastructure is acceptable in CI scripts but does not otherwise belong in the layer. --- build.sh | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100755 build.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index 7b96afd..0000000 --- a/build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -e - -# Configuration -SRC_ROOT="${SRC_ROOT:=$(pwd)}" -POKY_DIR="${POKY_DIR:=$SRC_ROOT/../poky}" -MACHINE="${MACHINE:=beaglebone-yocto}" - -# Build Yocto Poky -cd $POKY_DIR -source oe-init-build-env -bitbake-layers add-layer $SRC_ROOT -# Customize build -touch conf/sanity.conf -CONF_FILE=./conf/local.conf -rm -rf $CONF_FILE -echo "# Swift for Yocto" >> $CONF_FILE -echo "MACHINE=\"${MACHINE}\"" >> $CONF_FILE -#echo 'SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH"' >> $CONF_FILE -#echo "USER_CLASSES += \"buildstats buildstats-summary\"" >> $CONF_FILE - -# build Swift -bitbake swift-hello-world From 806b9346c6f894f358e09c0a93ec4a49773a3cf4 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 23 Jun 2025 08:32:24 +1000 Subject: [PATCH 05/41] explicitly specify TOOLCHAIN Swift can only build with the gcc toolchain; if the default toolchain is clang, we need to reset the toolchain to gcc. (Note that Swift itself uses its own clang.) --- classes/swift-cmake-base.bbclass | 3 ++- classes/swift.bbclass | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 6e28cb1..79d57ee 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -1,6 +1,7 @@ inherit cmake -DEPENDS_append += " swift-native libgcc gcc glibc " +# avoid conflicts with meta-clang +TOOLCHAIN = "gcc" DEPENDS:append = " swift-native libgcc gcc glibc " diff --git a/classes/swift.bbclass b/classes/swift.bbclass index faf8a74..3cda342 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -1,3 +1,5 @@ +# avoid conflicts with meta-clang +TOOLCHAIN = "gcc" DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch libfoundation" From 72d77c5d1b8d81ddc2383a68b13a487c45e67e35 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 23 Jun 2025 08:33:14 +1000 Subject: [PATCH 06/41] determine SWIFT_GCC_VERSION by examining bitbake's context dictionary Rather than hard-coding a specific GCC version, or relying on the current symbolic link (which breaks the Clang driver's version detection logic used by Swift's C++ interop), examine the bitbake context dictionary key RECIPE_MAINTAINER:pn-gcc-source-. Whilst something of a hack, this is the least worst option. Author: William Page --- classes/swift-cmake-base.bbclass | 60 ++++++++++---------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 79d57ee..1eeb578 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -9,6 +9,23 @@ SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aar SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', 'aarch64', d)}" +# Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key +# RECIPE_MAINTAINER:pn-gcc-source- +python () { + gcc_src_maint_pkg = [x for x in d if x.startswith("RECIPE_MAINTAINER:pn-gcc-source-")][0] + gcc_ver = gcc_src_maint_pkg.rpartition("-")[2] + + d.setVar("SWIFT_GCC_VERSION", gcc_ver) +} + +EXTRA_INCLUDE_FLAGS ?= "\ + -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION}/${TARGET_SYS} \ + -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION} \ + -I${STAGING_DIR_TARGET}" + +# not supported by clang +DEBUG_PREFIX_MAP:remove = "-fcanon-prefix-map" + HOST_CC_ARCH:prepend = "-target ${SWIFT_TARGET_NAME} " ################################################################################ @@ -31,8 +48,8 @@ OECMAKE_C_COMPILER = "clang" OECMAKE_CXX_COMPILER = "clang++" # Point clang to where the C++ runtime is for our target arch -RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" -TARGET_LDFLAGS += "-w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" +RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" +TARGET_LDFLAGS:append = " -w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" OECMAKE_C_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" OECMAKE_CXX_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" @@ -67,45 +84,6 @@ ${EXTRA_SWIFTC_FLAGS} \ HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/usr/lib" -EXTRANATIVEPATH += "swift-tools" - -################################################################################ -# Create symlinks to the directories containing the gcc version specific # -# headers, objects and libraries we need. # -# # -# We can't just use ${GCC_VERSION} in the path variables in the recipe # -# because bitbake parses and expands variables before GCC_VERSION is # -# defined. GCC_VERSION cannot be defined until the sysroot is populated # -# because we inspect the sysroot to determine the GCC version number string. # -# If there was an env or bitbake var with the GCC version, we could use that # -# and avoid all of this but the closest thing we have access to is # -# ${GCCVERSION} which yields and incomplete version number (ex: "9.%"). # -# # -# Also there is some suspicion that these path variables and these symlinks # -# may not be necessary if the --gcc-toolchain clang flag was used. But that # -# is an unproven theory. # -################################################################################ - -do_create_gcc_version_symlinks() { - GCC_VERSION=`basename ${STAGING_DIR_TARGET}/usr/include/c++/*` - - if [ ! -L "${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" ]; then - cd ${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS} - ln -s -r ${GCC_VERSION} current - fi - - if [ ! -L "${STAGING_DIR_TARGET}/usr/include/c++/current" ]; then - cd ${STAGING_DIR_TARGET}/usr/include/c++ - ln -s -r ${GCC_VERSION} current - fi - - if [ ! -L "${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/current" ]; then - cd ${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS} - ln -s -r ${GCC_VERSION} current - fi -} - -addtask do_create_gcc_version_symlinks after do_prepare_recipe_sysroot before do_configure EXTRA_OECMAKE:append = ' -DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' EXTRA_OECMAKE:append = " -DSWIFT_USE_LINKER=lld" EXTRA_OECMAKE:append = " -DLLVM_USE_LINKER=lld" From c64fcf1fa27fd062fc54d17c110eafcc1158d613 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:28:50 +1000 Subject: [PATCH 07/41] reformat swift-cmake-base.bbclass (indentation) A small indentation fix to swift-cmake-base.bbclass to be consistent with other recipes used by this layer. --- classes/swift-cmake-base.bbclass | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 1eeb578..848ea5a 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -66,20 +66,20 @@ BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" EXTRA_SWIFTC_FLAGS ??= "" SWIFT_FLAGS = "-target ${SWIFT_TARGET_NAME} -use-ld=lld \ --resource-dir ${STAGING_DIR_TARGET}/usr/lib/swift \ --module-cache-path ${B}/${BUILD_MODE}/ModuleCache \ --Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ --Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib \ --Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/current/include \ --Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/current/include-fixed \ --L${STAGING_DIR_TARGET} \ --L${STAGING_DIR_TARGET}/lib \ --L${STAGING_DIR_TARGET}/usr/lib \ --L${STAGING_DIR_TARGET}/usr/lib/swift \ --L${STAGING_DIR_TARGET}/usr/lib/swift/linux \ --L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ --sdk ${STAGING_DIR_TARGET} \ -${EXTRA_SWIFTC_FLAGS} \ + -resource-dir ${STAGING_DIR_TARGET}/usr/lib/swift \ + -module-cache-path ${B}/${BUILD_MODE}/ModuleCache \ + -Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib \ + -Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} \ + -Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION}/include \ + -Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION}/include-fixed \ + -L${STAGING_DIR_TARGET} \ + -L${STAGING_DIR_TARGET}/lib \ + -L${STAGING_DIR_TARGET}/usr/lib \ + -L${STAGING_DIR_TARGET}/usr/lib/swift \ + -L${STAGING_DIR_TARGET}/usr/lib/swift/linux \ + -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} \ + -sdk ${STAGING_DIR_TARGET} \ + ${EXTRA_SWIFTC_FLAGS} \ " HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/usr/lib" From 2223b0cfe8a4e57a05c544d1f8a36d526e60695f Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:32:42 +1000 Subject: [PATCH 08/41] separate out Swift package resolution from build tasks Separate out Swift package resolutions into a new do_swift_package_resolve() task. Ensure the ambient SSH_AUTH_SOCK is available to this task in order to support resolution of package dependencies in private repositories. Rewrite do_compile() task in Python, adding support for building Swift tests. --- classes/swift.bbclass | 124 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 9 deletions(-) diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 3cda342..d5c8da9 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -12,11 +12,21 @@ B ?= "${S}/.build" EXTERNALSRC_BUILD ?= "${EXTERNALSRC}/.build" BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" +BUILD_DIR = "${B}/${BUILD_MODE}" # Additional parameters to pass to SPM EXTRA_OESWIFT ?= "" SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" +SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aarch64', d)}" + +do_fix_gcc_install_dir() { + # symbolic links do not work, will not be found by Swift clang driver + # this is necessary to make the libstdc++ location heuristic work, necessary for C++ interop + (cd ${STAGING_DIR_TARGET}/usr/lib && rm -rf gcc && mkdir -p gcc && cp -rp ${SWIFT_TARGET_ARCH}-oe-linux gcc) +} + +addtask fix_gcc_install_dir before do_configure after do_prepare_recipe_sysroot # Workaround complex macros that cannot be automatically imported by Swift. # https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/using_imported_c_macros_in_swift @@ -41,6 +51,37 @@ def fix_socket_header(filename): else: f.write(line) +# Support for SwiftPM fetching packages and their GitHub submodules +do_swift_package_resolve[depends] += "unzip-native:do_populate_sysroot swift-native:do_populate_sysroot" +do_swift_package_resolve[network] = "1" +do_swift_package_resolve[vardepsexclude] = "BB_ORIGENV" + +python do_swift_package_resolve() { + import subprocess + import os + + s = d.getVar('S') + b = d.getVar('B') + + env = os.environ.copy() + + ssh_auth_sock = d.getVar('BB_ORIGENV').get('SSH_AUTH_SOCK') + if ssh_auth_sock: + env['SSH_AUTH_SOCK'] = ssh_auth_sock + + ret = subprocess.call(['swift', 'package', 'resolve', '--package-path', s, '--build-path', b], env=env) + if ret != 0: + bb.fatal('swift package resolve failed') + + # note: --depth 1 requires git version 2.43.0 or later + for package in os.listdir(path=f'{b}/checkouts'): + package_dir = f'{b}/checkouts/{package}' + ret = subprocess.call(['git', 'submodule', 'update', '--init', '--recursive', '--depth', '1'], cwd=package_dir, env=env) + if ret != 0: + bb.fatal('git submodule update failed') +} + +addtask swift_package_resolve after do_unpack before do_compile python swift_do_configure() { import os @@ -62,6 +103,8 @@ python swift_do_configure() { # This is used to determine necessary include paths cxx_include_base = recipe_sysroot + "/usr/include/c++" cxx_include_list = os.listdir(cxx_include_base) + if 'current' in cxx_include_list: + cxx_include_list.remove('current') if len(cxx_include_list) != 1: bb.fatal("swift bbclass detected more than one c++ runtime, unable to determine which one to use") cxx_version = cxx_include_list[0] @@ -71,22 +114,26 @@ python swift_do_configure() { swift_destination_template = """{ "version":1, "sdk":"${STAGING_DIR_TARGET}/", - "toolchain-bin-dir":"${STAGING_DIR_NATIVE}/opt/usr/bin", + "toolchain-bin-dir":"${STAGING_DIR_NATIVE}/usr/bin", "target":"${SWIFT_TARGET_NAME}", "dynamic-library-extension":"so", "extra-cc-flags":[ "-fPIC", + "-I${STAGING_INCDIR}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}/${TARGET_SYS}", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include-fixed" + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include", + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include-fixed" ], "extra-swiftc-flags":[ "-target", "${SWIFT_TARGET_NAME}", "-use-ld=lld", "-tools-directory", - "${STAGING_DIR_NATIVE}/opt/usr/bin", + "${STAGING_DIR_NATIVE}/usr/bin", + + "-enforce-exclusivity=unchecked", + "-enforce-exclusivity=none", "-Xlinker", "-rpath", "-Xlinker", "/usr/lib/swift/linux", @@ -111,14 +158,16 @@ python swift_do_configure() { "-I${STAGING_INCDIR}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}/${TARGET_SYS}", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include-fixed", + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include", + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include-fixed", "-resource-dir", "${STAGING_DIR_TARGET}/usr/lib/swift", "-module-cache-path", "${B}/${BUILD_MODE}/ModuleCache", "-Xclang-linker", "-B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_CXX_VERSION}", "-Xclang-linker", "-B${STAGING_DIR_TARGET}/usr/lib", + "-Xcc", "--gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_CXX_VERSION}", + "-sdk", "${STAGING_DIR_TARGET}" ], "extra-cpp-flags":[ @@ -135,10 +184,67 @@ python swift_do_configure() { configJSON.close() } -swift_do_compile() { - swift build --package-path ${S} --build-path ${B} --skip-update -c ${BUILD_MODE} --destination ${WORKDIR}/destination.json ${EXTRA_OESWIFT} +# ideally this should be handled by do_swift_package_resolve but doesn't always appear to be the case +do_compile[network] = "1" +swift_do_compile[vardepsexclude] = "BB_ORIGENV" + +python swift_do_compile() { + import subprocess + import os + import shlex + + s = d.getVar('S') + b = d.getVar('B') + build_mode = d.getVar('BUILD_MODE') + workdir = d.getVar("WORKDIR", True) + destination_json = workdir + '/destination.json' + extra_oeswift = shlex.split(d.getVar('EXTRA_OESWIFT')) + ssh_auth_sock = d.getVar('BB_ORIGENV').get('SSH_AUTH_SOCK') + recipe_sysroot = d.getVar("STAGING_DIR_TARGET", True) + + env = os.environ.copy() + if ssh_auth_sock: + env['SSH_AUTH_SOCK'] = ssh_auth_sock + env['SYSROOT'] = recipe_sysroot + + args = ['swift', 'build', '--package-path', s, '--build-path', b, '-c', build_mode, '--destination', destination_json] + extra_oeswift + + ret = subprocess.call(args, env=env, cwd=s) + if ret != 0: + bb.fatal('swift build failed') + + if d.getVar('SWIFT_BUILD_TESTS') == '1': + if d.getVar('DEBUG_BUILD') != '1': + bb.warn('building Swift tests with release build, @testable imports may fail') + + # FIXME: why do we need to specify -lXCTest and -lTesting explicitly + test_args = ['--build-tests', '-Xlinker', '-lXCTest', '-Xlinker', '-lTesting'] + ret = subprocess.call(args + test_args + extra_oeswift, env=env, cwd=s) + if ret != 0: + bb.fatal('swift build --build-tests failed') +} + +do_package_update() { + cd ${S} + swift package update + + # Iterate over the search dirs for this recipes' files + # The first one that has a Package.resolved is the one bitbake got the file + # from in the first places + RESOLVED_PATH="" + for i in $(echo "${FILESPATH}" | tr ':' '\n'); do + if [ -r "${i}"/Package.resolved ]; then + RESOLVED_PATH="${i}/Package.resolved" + cp Package.resolved "${RESOLVED_PATH}" + bbwarn "Replaced ${RESOLVED_PATH} with updated Package.resolved." + break + fi + done + [ -z "${RESOLVED_PATH}" ] && bbwarn "Updated Package.resolved located at ${S}/Package.resolved" || : } +do_package_update[network] = "1" +addtask do_package_update after do_configure -EXPORT_FUNCTIONS do_configure do_compile +EXPORT_FUNCTIONS do_configure do_compile do_package_update EXTRANATIVEPATH += "swift-tools" From a3d6c89450a7a3dccc39137d1addad089890c8aa Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:48:00 +1000 Subject: [PATCH 09/41] update Swift version from 5.7.1 to 6.1.2 Update the common include file specifying the Swift version to be built. --- recipes-devtools/swift/swift-version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes-devtools/swift/swift-version.inc b/recipes-devtools/swift/swift-version.inc index 787737a..70a1477 100644 --- a/recipes-devtools/swift/swift-version.inc +++ b/recipes-devtools/swift/swift-version.inc @@ -1 +1 @@ -SWIFT_VERSION = "5.7.1" +SWIFT_VERSION = "6.1.2" From d1de1a09fc2452a665586e78459b0c250d4f87b4 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:47:31 +1000 Subject: [PATCH 10/41] libdispatch: update for Scarthgap Update libdispatch for Scarthgap, with some cleanups to the summary and description. Add support for building separate -dev and -staticdev packages rather than including development-only products in the target image. --- recipes-devtools/swift/libdispatch.bb | 57 +++++++++++++++++++++------ 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/recipes-devtools/swift/libdispatch.bb b/recipes-devtools/swift/libdispatch.bb index 446453a..e1ef882 100644 --- a/recipes-devtools/swift/libdispatch.bb +++ b/recipes-devtools/swift/libdispatch.bb @@ -1,18 +1,19 @@ - -SUMMARY = "Libdispatch" -HOMEPAGE = "https://github.com/apple/swift-corelibs-libdispatch" +SUMMARY = "libdispatch" +DESCRIPTION = "The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware" +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-libdispatch" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" require swift-version.inc -PV = "${SWIFT_VERSION}" +PV = "${SWIFT_VERSION}+git${SRCPV}" -SRC_URI = "git://github.com/apple/swift-corelibs-libdispatch.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1" +DEPENDS = "swift-stdlib" -DEPENDS = "swift-stdlib ncurses" +SRC_URI = "git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" S = "${WORKDIR}/git" +LIBDISPATCH_BUILDDIR = "${WORKDIR}/build" inherit swift-cmake-base @@ -22,15 +23,45 @@ TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" # Ensure the right CPU is targeted -cmake_do_generate_toolchain_file_append() { +cmake_do_generate_toolchain_file:append() { sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake } -do_install_append() { - # Copy cmake build modules - mkdir -p ${D}${libdir}/swift/dispatch/cmake - cp -rf ${WORKDIR}/build/cmake/modules/* ${D}${libdir}/swift/dispatch/cmake/ +do_install:append() { + # move the header files out of /usr/lib/swift and into /usr/include, + # because we want Swift C shims to be able to pick them up without fancy + # SwiftPM magic + install -d ${D}${includedir} + (cd ${D}${libdir}/swift; mv Block os dispatch ${D}${includedir}) + + # don't install CMake modules as they have absolute paths in them +# install -d ${D}${libdir}/cmake/dispatch +# install -m 0644 ${LIBDISPATCH_BUILDDIR}/cmake/modules/dispatchConfig.cmake ${D}${libdir}/cmake/dispatch/ +# install -m 0644 ${LIBDISPATCH_BUILDDIR}/cmake/modules/dispatchExports.cmake ${D}${libdir}/cmake/dispatch/ } -FILES_${PN} = "${libdir}/swift/*" -INSANE_SKIP_${PN} = "file-rdeps" +FILES:${PN} = "\ + ${libdir}/swift/linux/libdispatch.so \ + ${libdir}/swift/linux/libswiftDispatch.so \ + ${libdir}/swift/linux/libBlocksRuntime.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftdoc \ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftmodule \ + ${includedir}/Block \ + ${includedir}/os \ + ${includedir}/dispatch \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/swift_static/linux/libdispatch.a \ + ${libdir}/swift_static/linux/libswiftDispatch.a \ + ${libdir}/swift_static/linux/libBlocksRuntime.a \ + ${libdir}/swift_static/linux/libDispatchStubs.a \ + ${libdir}/swift_static/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftdoc \ + ${libdir}/swift_static/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftmodule \ + ${libdir}/swift_static/linux/dispatch \ +" + +INSANE_SKIP:${PN} = "file-rdeps" From c84fd087d7867bccfa0271b75d4b55dedc2f8c57 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:43:52 +1000 Subject: [PATCH 11/41] remove external libicu dependency libicu is built as part of swift-foundation-icu; it does not need to be retrieved separately. --- recipes-support/icu/icu-swift.inc | 65 ------------------- .../0001-Disable-LDFLAGSICUDT-for-Linux.patch | 28 -------- .../icu/icu-swift/fix-install-manx.patch | 48 -------------- .../icu/icu-swift/icu-pkgdata-large-cmd.patch | 29 --------- recipes-support/icu/icu-swift_55.1.bb | 25 ------- 5 files changed, 195 deletions(-) delete mode 100644 recipes-support/icu/icu-swift.inc delete mode 100644 recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch delete mode 100644 recipes-support/icu/icu-swift/fix-install-manx.patch delete mode 100644 recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch delete mode 100644 recipes-support/icu/icu-swift_55.1.bb diff --git a/recipes-support/icu/icu-swift.inc b/recipes-support/icu/icu-swift.inc deleted file mode 100644 index 1428b9e..0000000 --- a/recipes-support/icu/icu-swift.inc +++ /dev/null @@ -1,65 +0,0 @@ -SUMMARY = "International Component for Unicode libraries" -DESCRIPTION = "The International Component for Unicode (ICU) is a mature, \ -portable set of C/C++ and Java libraries for Unicode support, software \ -internationalization (I18N) and globalization (G11N), giving applications the \ -same results on all platforms." -HOMEPAGE = "http://site.icu-project.org/" - -LICENSE = "ICU" -DEPENDS = "icu-swift-native" -DEPENDS_class-native = "" - -S = "${WORKDIR}/icu/source" -SPDX_S = "${WORKDIR}/icu" -STAGING_ICU_DIR_NATIVE = "${STAGING_DATADIR_NATIVE}/${BPN}/${PV}" - -CPPFLAGS_append_libc-uclibc = " -DU_TIMEZONE=0" - -inherit autotools pkgconfig - -# ICU needs the native build directory as an argument to its --with-cross-build option when -# cross-compiling. Taken the situation that different builds may share a common sstate-cache -# into consideration, the native build directory needs to be staged. -EXTRA_OECONF = "--with-cross-build=${STAGING_ICU_DIR_NATIVE}" -EXTRA_OECONF_class-native = "" -EXTRA_OECONF_class-nativesdk = "--with-cross-build=${STAGING_ICU_DIR_NATIVE}" - -PREPROCESS_RELOCATE_DIRS = "${datadir}/${BPN}/${PV}" -do_install_append_class-native() { - mkdir -p ${D}/${STAGING_ICU_DIR_NATIVE}/config - cp -r ${B}/config/icucross.mk ${D}/${STAGING_ICU_DIR_NATIVE}/config - cp -r ${B}/config/icucross.inc ${D}/${STAGING_ICU_DIR_NATIVE}/config - cp -r ${B}/lib ${D}/${STAGING_ICU_DIR_NATIVE} - cp -r ${B}/bin ${D}/${STAGING_ICU_DIR_NATIVE} - cp -r ${B}/tools ${D}/${STAGING_ICU_DIR_NATIVE} - - rm -r ${D}${STAGING_BINDIR_NATIVE} - rm -r ${D}${STAGING_SBINDIR_NATIVE} - rm -r ${D}${STAGING_LIBDIR_NATIVE} - rm -r ${D}${STAGING_DATADIR_NATIVE}/icu -} - -do_install_append() { - rm -rf ${D}/usr/lib/icu - rm -rf ${D}/usr/share/icu - rm -f ${D}/${libdir}/*.so - rm -rf ${D}/${bindir} - rm -rf ${D}/usr/sbin - rm -rf ${D}/${includedir} - rm -rf ${D}/usr/lib/pkgconfig -} - -PACKAGES =+ "libicudata-swift libicuuc-swift libicui18n-swift libicule-swift libiculx-swift libicutu-swift libicuio-swift" - -FILES_${PN}-dev += "${libdir}/${BPN}/" - -FILES_libicudata-swift = "${libdir}/libicudata.so.*" -FILES_libicuuc-swift = "${libdir}/libicuuc.so.*" -FILES_libicui18n-swift = "${libdir}/libicui18n.so.*" -FILES_libicule-swift = "${libdir}/libicule.so.*" -FILES_libiculx-swift = "${libdir}/libiculx.so.*" -FILES_libicutu-swift = "${libdir}/libicutu.so.*" -FILES_libicuio-swift = "${libdir}/libicuio.so.*" - -BBCLASSEXTEND = "native" - diff --git a/recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch b/recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch deleted file mode 100644 index 2968d57..0000000 --- a/recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0c82d6aa02c08e41b13c83b14782bd7024e25d59 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Sat, 15 Feb 2014 21:06:42 +0000 -Subject: [PATCH] Disable LDFLAGSICUDT for Linux - -Upstream-Status: Inappropriate [ OE Configuration ] - -Signed-off-by: Khem Raj ---- - source/config/mh-linux | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/config/mh-linux b/config/mh-linux -index 366f0cc..2689aab 100644 ---- a/config/mh-linux -+++ b/config/mh-linux -@@ -21,7 +21,7 @@ LD_RPATH= -Wl,-zorigin,-rpath,'$$'ORIGIN - LD_RPATH_PRE = -Wl,-rpath, - - ## These are the library specific LDFLAGS --LDFLAGSICUDT=-nodefaultlibs -nostdlib -+# LDFLAGSICUDT=-nodefaultlibs -nostdlib - - ## Compiler switch to embed a library name - # The initial tab in the next line is to prevent icu-config from reading it. --- -1.7.10.4 - diff --git a/recipes-support/icu/icu-swift/fix-install-manx.patch b/recipes-support/icu/icu-swift/fix-install-manx.patch deleted file mode 100644 index ec63f50..0000000 --- a/recipes-support/icu/icu-swift/fix-install-manx.patch +++ /dev/null @@ -1,48 +0,0 @@ -The generic recursive target calls target-local so also adding it to the -dependency list results in races due to install-local being executed twice in -parallel. For example, install-manx can fail if the two install processes race -and one process tries to chown a file that the other process has just deleted. - -Also install-manx should be a phony target, and for clarity use $^ instead of $? -in the install command. - -Upstream-Status: Pending -Signed-off-by: Ross Burton - - -diff --git a/Makefile.in b/Makefile.in -index 9db6c52..3441afa 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -71,7 +71,7 @@ EXTRA_DATA = - - ## List of phony targets - .PHONY : all all-local all-recursive install install-local install-udata install-udata-files install-udata-dlls \ --install-recursive clean clean-local clean-recursive distclean \ -+install-recursive install-manx clean clean-local clean-recursive distclean \ - distclean-local distclean-recursive doc dist dist-local dist-recursive \ - check check-local check-recursive clean-recursive-with-twist install-icu \ - doc install-doc tests icu4j-data icu4j-data-install update-windows-makefiles xcheck-local xcheck-recursive xperf xcheck xperf-recursive \ -@@ -82,10 +82,10 @@ check-exhaustive check-exhaustive-local check-exhaustive-recursive releaseDist - - ## List of standard targets - all: all-local all-recursive --install: install-recursive install-local -+install: install-recursive - clean: clean-recursive-with-twist clean-local --distclean : distclean-recursive distclean-local --dist: dist-recursive dist-local -+distclean : distclean-recursive -+dist: dist-recursive - check: all check-recursive - check-recursive: all - xcheck: all xcheck-recursive -@@ -352,7 +352,7 @@ config.status: $(srcdir)/configure $(srcdir)/common/unicode/uvernum.h - - install-manx: $(MANX_FILES) - $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION) -- $(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION) -+ $(INSTALL_DATA) $^ $(DESTDIR)$(mandir)/man$(SECTION) - - config/%.$(SECTION): $(srcdir)/config/%.$(SECTION).in - cd $(top_builddir) \ diff --git a/recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch b/recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch deleted file mode 100644 index 6e40659..0000000 --- a/recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch +++ /dev/null @@ -1,29 +0,0 @@ -pkgdata.cpp: use LARGE_BUFFER_MAX_SIZE for cmd - -Use LARGE_BUFFER_MAX_SIZE for cmd rather than SMALL_BUFFER_MAX_SIZE, -otherwise there was a Segmentation fault error when the command line is -long, this should be a misplay since other cmd uses -LARGE_BUFFER_MAX_SIZE. - -Upstream-Status: Pending - -Signed-off-by: Robert Yang ---- - tools/pkgdata/pkgdata.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/pkgdata/pkgdata.cpp b/tools/pkgdata/pkgdata.cpp ---- a/tools/pkgdata/pkgdata.cpp -+++ b/tools/pkgdata/pkgdata.cpp -@@ -1019,7 +1019,7 @@ normal_symlink_mode: - - static int32_t pkg_installLibrary(const char *installDir, const char *targetDir, UBool noVersion) { - int32_t result = 0; -- char cmd[SMALL_BUFFER_MAX_SIZE]; -+ char cmd[LARGE_BUFFER_MAX_SIZE]; - - sprintf(cmd, "cd %s && %s %s %s%s%s", - targetDir, --- -1.7.10.4 - diff --git a/recipes-support/icu/icu-swift_55.1.bb b/recipes-support/icu/icu-swift_55.1.bb deleted file mode 100644 index 6a91ea6..0000000 --- a/recipes-support/icu/icu-swift_55.1.bb +++ /dev/null @@ -1,25 +0,0 @@ -require icu-swift.inc - -LIC_FILES_CHKSUM = "file://../license.html;md5=64eff4aadff4d104d6d437c4fde0e6d7" - -def icu_download_version(d): - pvsplit = d.getVar('PV', True).split('.') - return pvsplit[0] + "_" + pvsplit[1] - -ICU_PV = "${@icu_download_version(d)}" - -# http://errors.yoctoproject.org/Errors/Details/20486/ -ARM_INSTRUCTION_SET_armv4 = "arm" -ARM_INSTRUCTION_SET_armv5 = "arm" - -BASE_SRC_URI = "http://download.icu-project.org/files/icu4c/${PV}/icu4c-${ICU_PV}-src.tgz" -SRC_URI = "${BASE_SRC_URI} \ - file://icu-pkgdata-large-cmd.patch \ - file://fix-install-manx.patch \ - " - -SRC_URI_append_class-target = "\ - file://0001-Disable-LDFLAGSICUDT-for-Linux.patch \ - " -SRC_URI[md5sum] = "e2d523df79d6cb7855c2fbe284f4db29" -SRC_URI[sha256sum] = "e16b22cbefdd354bec114541f7849a12f8fc2015320ca5282ee4fd787571457b" From 02f5776d8aa7813d595b1b95c5206eb54682a48f Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 23 Jun 2025 13:28:21 +1000 Subject: [PATCH 12/41] swift-foundation: update for 6.1.2 and Scarthgap The new Swift Foundation is separated into FoundationEssentials, FoundationICU and Foundation. Create separate recipes for all three. Add support for building separate -dev and -staticdev packages rather than including development-only products in the target image --- recipes-devtools/swift/libfoundation.bb | 54 ------- ...Config.cmake-not-depend-on-build-dir.patch | 153 ------------------ .../swift/swift-foundation-essentials.bb | 64 ++++++++ .../swift/swift-foundation-icu.bb | 42 +++++ recipes-devtools/swift/swift-foundation.bb | 85 ++++++++++ 5 files changed, 191 insertions(+), 207 deletions(-) delete mode 100644 recipes-devtools/swift/libfoundation.bb delete mode 100644 recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch create mode 100644 recipes-devtools/swift/swift-foundation-essentials.bb create mode 100644 recipes-devtools/swift/swift-foundation-icu.bb create mode 100644 recipes-devtools/swift/swift-foundation.bb diff --git a/recipes-devtools/swift/libfoundation.bb b/recipes-devtools/swift/libfoundation.bb deleted file mode 100644 index a740c13..0000000 --- a/recipes-devtools/swift/libfoundation.bb +++ /dev/null @@ -1,54 +0,0 @@ -SUMMARY = "The Foundation framework defines a base layer of functionality that is required for almost all applications." -HOMEPAGE = "https://github.com/apple/swift-corelibs-foundation" - -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" - -require swift-version.inc -PV = "${SWIFT_VERSION}" - -SRC_URI = "git://github.com/apple/swift-corelibs-foundation.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1" - -S = "${WORKDIR}/git" - -DEPENDS = "swift-stdlib libdispatch ncurses libxml2 icu curl" -RDEPENDS_${PN} += "swift-stdlib libdispatch" - -inherit swift-cmake-base - -TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" - -# Enable Swift parts -EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" -EXTRA_OECMAKE += '-DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' -EXTRA_OECMAKE += '-DCMAKE_VERBOSE_MAKEFILE=ON' -EXTRA_OECMAKE += '-DCF_DEPLOYMENT_SWIFT=ON' -lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" - -EXTRA_OECMAKE+= "-Ddispatch_DIR=${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/cmake" - -# Ensure the right CPU is targeted -cmake_do_generate_toolchain_file_append() { - sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake -} - -do_configure_append() { - # Workaround Dispatch defined with cmake and module - mkdir -p /tmp/dispatch - cp -rf ${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/module.modulemap /tmp/dispatch/module.modulemap - rm -rf ${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/module.modulemap -} - -do_install_append() { - # No need to install the plutil onto the target, so remove it for now - rm ${D}${bindir}/plutil - - # Since plutil was the only thing in the bindir, remove the bindir as well - rmdir ${D}${bindir} - - # Restore Dispatch - cp -rf /tmp/dispatch/module.modulemap ${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/module.modulemap -} - -FILES_${PN} = "${libdir}/swift/*" -INSANE_SKIP_${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch b/recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch deleted file mode 100644 index 6d812d8..0000000 --- a/recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch +++ /dev/null @@ -1,153 +0,0 @@ -From dd935a79df0f931ec476b9df94598e923e3799f3 Mon Sep 17 00:00:00 2001 -From: Kevin Peizner -Date: Wed, 28 Oct 2020 14:24:16 -0700 -Subject: [PATCH] Make FoundationConfig.cmake not depend on build dir - -The default FoundationConfig.cmake generated file depends on the -generated FoundationExports.cmake file via a build dir specific path. - -Furthermore, the original FoundationExports.cmake contains build dir -specific paths. - -This breaks inclusion in other projects unless said project has access -to the build & src tree of libfoundation. - -This commit changes the FoundationConfig.cmake & FoundationExports.cmake -files so that the paths within them are based relative to the -installation of libfoundation. ---- - Sources/Foundation/CMakeLists.txt | 8 ++++--- - Sources/FoundationNetworking/CMakeLists.txt | 8 ++++--- - Sources/FoundationXML/CMakeLists.txt | 8 ++++--- - cmake/modules/CMakeLists.txt | 25 ++++++++++++++++----- - cmake/modules/FoundationConfig.cmake.in | 10 ++++++++- - 5 files changed, 44 insertions(+), 15 deletions(-) - -diff --git a/Sources/Foundation/CMakeLists.txt b/Sources/Foundation/CMakeLists.txt -index 5628fdae..103ab258 100644 ---- a/Sources/Foundation/CMakeLists.txt -+++ b/Sources/Foundation/CMakeLists.txt -@@ -149,8 +149,10 @@ target_link_libraries(Foundation - set_target_properties(Foundation PROPERTIES - INSTALL_RPATH "$ORIGIN" - BUILD_RPATH "$" -- Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift -- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) -+ Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) -+target_include_directories(Foundation INTERFACE -+ $ -+ $) - - if(CMAKE_SYSTEM_NAME STREQUAL Windows) - # NOTE: workaround for CMake which doesn't link in OBJECT libraries properly -@@ -163,7 +165,7 @@ endif() - - - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation) --install(TARGETS Foundation -+install(TARGETS Foundation EXPORT FoundationExports - ARCHIVE DESTINATION lib/swift$<$>:_static>/$ - LIBRARY DESTINATION lib/swift$<$>:_static>/$ - RUNTIME DESTINATION bin) -diff --git a/Sources/FoundationNetworking/CMakeLists.txt b/Sources/FoundationNetworking/CMakeLists.txt -index 2ea3924c..8c31a0ce 100644 ---- a/Sources/FoundationNetworking/CMakeLists.txt -+++ b/Sources/FoundationNetworking/CMakeLists.txt -@@ -63,8 +63,10 @@ target_link_libraries(FoundationNetworking - Foundation) - set_target_properties(FoundationNetworking PROPERTIES - INSTALL_RPATH "$ORIGIN" -- Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift -- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) -+ Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) -+target_include_directories(FoundationNetworking INTERFACE -+ $ -+ $) - - if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") - target_link_options(FoundationNetworking PRIVATE "SHELL:-no-toolchain-stdlib-rpath") -@@ -72,7 +74,7 @@ endif() - - - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking) --install(TARGETS FoundationNetworking -+install(TARGETS FoundationNetworking EXPORT FoundationNetworkingExports - ARCHIVE DESTINATION lib/swift$<$>:_static>/$ - LIBRARY DESTINATION lib/swift$<$>:_static>/$ - RUNTIME DESTINATION bin) -diff --git a/Sources/FoundationXML/CMakeLists.txt b/Sources/FoundationXML/CMakeLists.txt -index a11e0272..b573cc8e 100644 ---- a/Sources/FoundationXML/CMakeLists.txt -+++ b/Sources/FoundationXML/CMakeLists.txt -@@ -17,8 +17,10 @@ target_link_libraries(FoundationXML - Foundation) - set_target_properties(FoundationXML PROPERTIES - INSTALL_RPATH "$ORIGIN" -- Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift -- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) -+ Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) -+target_include_directories(FoundationXML INTERFACE -+ $ -+ $) - - if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") - target_link_options(FoundationXML PRIVATE "SHELL:-no-toolchain-stdlib-rpath") -@@ -26,7 +28,7 @@ endif() - - - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML) --install(TARGETS FoundationXML -+install(TARGETS FoundationXML EXPORT FoundationXMLExports - ARCHIVE DESTINATION lib/swift$<$>:_static>/$ - LIBRARY DESTINATION lib/swift$<$>:_static>/$ - RUNTIME DESTINATION bin) -diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt -index 3dbaaace..02e971da 100644 ---- a/cmake/modules/CMakeLists.txt -+++ b/cmake/modules/CMakeLists.txt -@@ -1,7 +1,22 @@ - --set(Foundation_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/FoundationExports.cmake) --configure_file(FoundationConfig.cmake.in -- ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake) -+set(INCLUDE_INSTALL_DIR lib/swift) -+set(LIB_INSTALL_DIR lib/swift) -+ -+include(CMakePackageConfigHelpers) -+configure_package_config_file(FoundationConfig.cmake.in -+ ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake -+ INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake -+ PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR) -+ -+#write_basic_package_version_file( -+# ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfigVersion.cmake -+# VERSION 1.2.3 -+# COMPATIBILITY SameMajorVersion ) -+ -+install(EXPORT FoundationExports DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake) -+install(EXPORT FoundationNetworkingExports DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake) -+install(EXPORT FoundationXMLExports DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake) -+install(FILES -+ ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake -+ DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake ) - --get_property(Foundation_EXPORTS GLOBAL PROPERTY Foundation_EXPORTS) --export(TARGETS ${Foundation_EXPORTS} FILE ${Foundation_EXPORTS_FILE}) -diff --git a/cmake/modules/FoundationConfig.cmake.in b/cmake/modules/FoundationConfig.cmake.in -index 77f0b76f..30a58e28 100644 ---- a/cmake/modules/FoundationConfig.cmake.in -+++ b/cmake/modules/FoundationConfig.cmake.in -@@ -1,4 +1,12 @@ - -+@PACKAGE_INIT@ -+set_and_check(FOUNDATION_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") -+set_and_check(FOUNDATION_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") -+ -+check_required_components(Foundation) -+ - if(NOT TARGET Foundation) -- include(@Foundation_EXPORTS_FILE@) -+ include(${FOUNDATION_LIB_DIR}/Foundation/cmake/FoundationExports.cmake) -+ include(${FOUNDATION_LIB_DIR}/Foundation/cmake/FoundationNetworkingExports.cmake) -+ include(${FOUNDATION_LIB_DIR}/Foundation/cmake/FoundationXMLExports.cmake) - endif() diff --git a/recipes-devtools/swift/swift-foundation-essentials.bb b/recipes-devtools/swift/swift-foundation-essentials.bb new file mode 100644 index 0000000..98e9cda --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-essentials.bb @@ -0,0 +1,64 @@ +SUMMARY = "FoundationEssentials" +DESCRIPTION = "Foundation provides a base layer of functionality useful in many applications, including fundamental types for numbers, data, collections, and dates, as well as functions for task management, file system access, and more." +HOMEPAGE = "https://github.com/swiftlang/swift-foundation" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2380e856fbdbc7ccae6bd699d53ec121" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "foundation_icu_syntax_collections" + +SRC_URI = "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;" +SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/apple/swift-collections.git;protocol=https;nobranch=1;name=collections;tag=1.1.4;destsuffix=swift-collections;" + +S = "${WORKDIR}/git" + +DEPENDS = "icu swift-stdlib swift-native swift-foundation-icu" +RDEPENDS:${PN} += "icu swift-stdlib swift-foundation-icu" + +inherit swift-cmake-base + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" + +# Enable Swift parts +EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" +EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" +EXTRA_OECMAKE += "-D_SwiftFoundationICU_SourceDIR=${WORKDIR}/swift-foundation-icu" +EXTRA_OECMAKE += "-D_SwiftCollections_SourceDIR=${WORKDIR}/swift-collections" +EXTRA_OECMAKE += "-DSwiftFoundation_MODULE_TRIPLE=${SWIFT_TARGET_NAME}" +EXTRA_OECMAKE += "-DSwiftSyntax_DIR=${WORKDIR}/swift-syntax/cmake/modules" + +lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" + +# Ensure the right CPU is targeted +cmake_do_generate_toolchain_file:append() { + sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake +} + +do_install:append() { + # don't double up on Unicode + rm -rf ${D}${libdir}/swift/_foundation_unicode + rm -rf ${D}${libdir}/swift/linux/lib_FoundationICU.so +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libFoundationEssentials.so \ + ${libdir}/swift/linux/libFoundationInternationalization.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/_FoundationCShims/* \ + ${libdir}/swift/linux/FoundationEssentials.swiftmodule/* \ + ${libdir}/swift/linux/FoundationInternationalization.swiftmodule/* \ + ${libdir}/swift/linux/_FoundationCollections.swiftmodule/* \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/lib_SwiftLibraryPluginProviderCShims.a \ + ${libdir}/swift_static/linux/libFoundationEssentials.a \ +" + +INSANE_SKIP:${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/swift-foundation-icu.bb b/recipes-devtools/swift/swift-foundation-icu.bb new file mode 100644 index 0000000..98a5f5b --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-icu.bb @@ -0,0 +1,42 @@ +SUMMARY = "swift-foundation-icu" +DESCRIPTION = "This version of the ICU4C project contains customized extensions for use by the Foundation package." +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-foundation-icu" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2380e856fbdbc7ccae6bd699d53ec121" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" + +SRC_URI = "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;" + +S = "${WORKDIR}/git" + +DEPENDS = "icu swift-stdlib" +RDEPENDS:${PN} += "swift-stdlib" + +inherit swift-cmake-base + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" + +# Enable Swift parts +EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" +EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" + +lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" + +# Ensure the right CPU is targeted +cmake_do_generate_toolchain_file:append() { + sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/lib_FoundationICU.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/_foundation_unicode/* \ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH}/FoundationICU.swiftmodule/* \ +" + +INSANE_SKIP:${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/swift-foundation.bb b/recipes-devtools/swift/swift-foundation.bb new file mode 100644 index 0000000..954a65a --- /dev/null +++ b/recipes-devtools/swift/swift-foundation.bb @@ -0,0 +1,85 @@ +SUMMARY = "Foundation" +DESCRIPTION = "The Foundation framework defines a base layer of functionality that is required for almost all applications." +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-foundation" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "corelibs_foundation_icu_syntax" + +SRC_URI = "git://github.com/swiftlang/swift-corelibs-foundation.git;protocol=https;name=corelibs;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;" +SRC_URI += "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation;" +SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax;" + +S = "${WORKDIR}/git" + +DEPENDS = "swift-foundation-essentials swift-foundation-icu swift-stdlib swift-native libdispatch ncurses libxml2 icu curl" +RDEPENDS:${PN} += "swift-foundation-essentials swift-stdlib libdispatch" + +inherit swift-cmake-base + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}${libdir}/swift/linux" + +OECMAKE_C_FLAGS += "-I${STAGING_DIR_TARGET}${libdir}/swift" + +EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" +EXTRA_OECMAKE += "-DCMAKE_VERBOSE_MAKEFILE=ON" +EXTRA_OECMAKE += "-DCF_DEPLOYMENT_SWIFT=ON" + +EXTRA_OECMAKE += "-D_SwiftFoundation_SourceDIR=${S}/swift-foundation" +EXTRA_OECMAKE += "-D_SwiftFoundationICU_SourceDIR=${S}/swift-foundation-icu" +EXTRA_OECMAKE += "-DSwiftFoundation_MODULE_TRIPLE=${SWIFT_TARGET_NAME}" + +EXTRA_OECMAKE += "-DCMAKE_FIND_ROOT_PATH:PATH=${CROSS_COMPILE_DEPS_PATH}" + +EXTRA_OECMAKE += "-Ddispatch_DIR=${STAGING_DIR_TARGET}${libdir}/cmake/dispatch" +EXTRA_OECMAKE += "-DSwiftSyntax_DIR=${STAGING_DIR_TARGET}${libdir}/cmake/dispatch" +EXTRA_OECMAKE += "-DENABLE_TESTING=0" +EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" +EXTRA_OECMAKE += "-DDISPATCH_INCLUDE_PATH=${STAGING_DIR_TARGET}/${includedir}" + +lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" + +# Ensure the right CPU is targeted +cmake_do_generate_toolchain_file:append() { + sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake +} + +do_install:append() { + # don't double up on Unicode + rm -rf ${D}${libdir}/swift/_foundation_unicode + + # No need to install the plutil onto the target, so remove it for now + rm ${D}${bindir}/plutil + + # Since plutil was the only thing in the bindir, remove the bindir as well + rmdir ${D}${bindir} + + # Don't install CMake modules until absolute paths are corrected +# install -d ${D}${libdir}/cmake/Foundation +# install -m 0644 ${S}/cmake/modules/FoundationConfig.cmake ${D}${libdir}/cmake/Foundation +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libFoundation.so \ + ${libdir}/swift/linux/libFoundationNetworking.so \ + ${libdir}/swift/linux/libFoundationXML.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/CoreFoundation/* \ + ${libdir}/swift/linux/Foundation.swiftmodule/* \ + ${libdir}/swift/linux/FoundationNetworking.swiftmodule/* \ + ${libdir}/swift/linux/FoundationXML.swiftmodule/* \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/swift/linux/libFoundation.a \ + ${libdir}/swift/linux/libFoundationNetworking.a \ + ${libdir}/swift/linux/libFoundationXML.a \ +" + +INSANE_SKIP:${PN} = "file-rdeps" From f1a9aee1d29d753d73a3aca4e2629112c43847cd Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 23 Jun 2025 13:29:21 +1000 Subject: [PATCH 13/41] enable CF timer tolerance APIs on non-Darwin platforms CFRunLoopTimerGetTolerance() and CFRunLoopTimerSetTolerance() are only available on macOS by default. Enable for all platforms. --- recipes-devtools/swift/swift-foundation.bb | 1 + ...tTolerance-CFRunLoopTimerSetToleranc.patch | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch diff --git a/recipes-devtools/swift/swift-foundation.bb b/recipes-devtools/swift/swift-foundation.bb index 954a65a..b0d1daf 100644 --- a/recipes-devtools/swift/swift-foundation.bb +++ b/recipes-devtools/swift/swift-foundation.bb @@ -13,6 +13,7 @@ SRC_URI = "git://github.com/swiftlang/swift-corelibs-foundation.git;protocol=htt SRC_URI += "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation;" SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax;" +SRC_URI += "file://0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch;striplevel=1;" S = "${WORKDIR}/git" diff --git a/recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch b/recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch new file mode 100644 index 0000000..d4437c1 --- /dev/null +++ b/recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch @@ -0,0 +1,44 @@ +From a38fd03fd9411ac5ffa94a523f0228f8ef75f058 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Tue, 4 Mar 2025 12:58:32 +1100 +Subject: [PATCH] CFRunLoopTimerGetTolerance/CFRunLoopTimerSetTolerance for + non-Mac + +--- + Sources/CoreFoundation/CFRunLoop.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/Sources/CoreFoundation/CFRunLoop.c b/Sources/CoreFoundation/CFRunLoop.c +index 91299fc5..3d2ed85d 100644 +--- a/Sources/CoreFoundation/CFRunLoop.c ++++ b/Sources/CoreFoundation/CFRunLoop.c +@@ -4735,18 +4735,13 @@ void CFRunLoopTimerGetContext(CFRunLoopTimerRef rlt, CFRunLoopTimerContext *cont + } + + CFTimeInterval CFRunLoopTimerGetTolerance(CFRunLoopTimerRef rlt) { +-#if TARGET_OS_MAC + CHECK_FOR_FORK(); + CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), CFTimeInterval, (NSTimer *)rlt, tolerance); + __CFGenericValidateType(rlt, CFRunLoopTimerGetTypeID()); + return rlt->_tolerance; +-#else +- return 0.0; +-#endif + } + + void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef rlt, CFTimeInterval tolerance) { +-#if TARGET_OS_MAC + CHECK_FOR_FORK(); + CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), void, (NSTimer *)rlt, setTolerance:tolerance); + __CFGenericValidateType(rlt, CFRunLoopTimerGetTypeID()); +@@ -4764,7 +4759,6 @@ void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef rlt, CFTimeInterval tolerance) + if (tolerance < 0) tolerance = 0.0; + rlt->_tolerance = tolerance; + } +-#endif + } + + #endif /* __HAS_DISPATCH__ */ +-- +2.39.5 (Apple Git-154) + From 3c61c1ac9d016beb4b6f1d6278153b2921dfb9c8 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:51:21 +1000 Subject: [PATCH 14/41] swift-native: update for 6.1.2 and Scarthgap Update the native Swift toolchain for Swift 6.1.2 and Scarthgap. --- recipes-devtools/swift/swift-native.bb | 63 ++++++++++++++------------ 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/recipes-devtools/swift/swift-native.bb b/recipes-devtools/swift/swift-native.bb index 6197e49..c9e73a9 100644 --- a/recipes-devtools/swift/swift-native.bb +++ b/recipes-devtools/swift/swift-native.bb @@ -1,5 +1,5 @@ -SUMMARY = "Swift toolchain for Linux" -HOMEPAGE = "https://swift.org/download/#releases" +SUMMARY = "Swift native toolchain for Linux" +HOMEPAGE = "https://swift.org/install/" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${S}/usr/share/swift/LICENSE.txt;md5=f6c482a0548ea60d6c2e015776534035" @@ -7,13 +7,31 @@ LIC_FILES_CHKSUM = "file://${S}/usr/share/swift/LICENSE.txt;md5=f6c482a0548ea60d require swift-version.inc PV = "${SWIFT_VERSION}" -SRC_DIR = "swift-${PV}-RELEASE-ubuntu20.04" -SRC_URI = "https://download.swift.org/swift-${PV}-release/ubuntu2004/swift-${PV}-RELEASE/swift-${PV}-RELEASE-ubuntu20.04.tar.gz" -SRC_URI[sha256sum] = "b014975844beac5ab3a7f71420181f45d0a93243f9ea4853e6588c05cad1e363" +def swift_native_arch_suffix(d): + host_arch = d.getVar('HOST_ARCH') + if host_arch == 'x86_64': + return '' + else: + return f'-{host_arch}' + +def swift_native_arch_checksum(d): + sha256 = { + "x86_64": "d749d5fe2d6709ee988e96b16f02bca7b53304d09925e31063fd5ec56019de9f", + "aarch64": "0be937ec11860cad109ab422541643f7c6b1156daa91c9e2c70d8f03ce245cb6" + } + + host_arch = d.getVar('HOST_ARCH') + return sha256[host_arch] + +SWIFT_ARCH_SUFFIX = "${@swift_native_arch_suffix(d)}" + +SRC_DIR = "swift-${SWIFT_VERSION}-RELEASE-ubuntu24.04${SWIFT_ARCH_SUFFIX}" +SRC_URI = "https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2404${SWIFT_ARCH_SUFFIX}/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu24.04${SWIFT_ARCH_SUFFIX}.tar.gz" +SRC_URI[sha256sum] = "${@swift_native_arch_checksum(d)}" DEPENDS = "curl" -RDEPENDS = "ncurses-native" - +RDEPENDS:${PN} = "ncurses-native" + S = "${WORKDIR}/${SRC_DIR}" inherit native @@ -21,31 +39,20 @@ inherit native ######################################################################## # This informs bitbake that we want to install a non-default directory # # in the native sysroot. # -# # -# We install the swift toolchain into opt to avoid conflicts with # -# other packages when installing. Ex: # -# # -# The file /usr/include/unicode/sortkey.h is installed by both # -# swift-native and icu-native, aborting # -# # ######################################################################## -SYSROOT_DIRS_NATIVE += "${base_prefix}/opt" - -do_install_append () { - install -d ${D}${base_prefix}/opt/usr/bin/ - cp -r ${S}/usr/bin/* ${D}${base_prefix}/opt/usr/bin/ - install -d ${D}${bindir}/ - ln -s ../../opt/usr/bin ${D}${bindir}/swift-tools +do_install:append () { + install -d ${D}${bindir} + cp -r ${S}/usr/bin/* ${D}${bindir} - install -d ${D}${base_prefix}/opt/usr/lib/ - cp -r ${S}/usr/lib/* ${D}${base_prefix}/opt/usr/lib/ + install -d ${D}${libdir} + cp -rd ${S}/usr/lib/* ${D}${libdir} - install -d ${D}${base_prefix}/opt/usr/include/ - cp -r ${S}/usr/include/* ${D}${base_prefix}/opt/usr/include/ + install -d ${D}${includedir} + cp -rd ${S}/usr/include/* ${D}${includedir} - install -d ${D}${base_prefix}/opt/usr/share/ - cp -r ${S}/usr/share/* ${D}${base_prefix}/opt/usr/share/ + install -d ${D}${datadir} + cp -rd ${S}/usr/share/* ${D}${datadir} } -FILES_${PN} += "${base_prefix}/opt/*" +FILES:${PN} += "${base_prefix}/*" From 4c86ea148378011c8f8edc6f40545bdc3e8896e6 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:51:37 +1000 Subject: [PATCH 15/41] swift-stdlib: update for Swift 6.1.2 and Scarthgap --- recipes-devtools/swift/swift-llvm-native.bb | 27 -- recipes-devtools/swift/swift-stdlib.bb | 275 ++++++++++++++---- .../swift/swift-stdlib/0001-Float16.patch | 22 -- .../cmake-configure-swift-stdlib.sh | 104 ------- .../swift/swift-stdlib/fix_modulemap.sh | 63 ---- 5 files changed, 219 insertions(+), 272 deletions(-) delete mode 100644 recipes-devtools/swift/swift-llvm-native.bb delete mode 100644 recipes-devtools/swift/swift-stdlib/0001-Float16.patch delete mode 100755 recipes-devtools/swift/swift-stdlib/cmake-configure-swift-stdlib.sh delete mode 100755 recipes-devtools/swift/swift-stdlib/fix_modulemap.sh diff --git a/recipes-devtools/swift/swift-llvm-native.bb b/recipes-devtools/swift/swift-llvm-native.bb deleted file mode 100644 index 1b42f81..0000000 --- a/recipes-devtools/swift/swift-llvm-native.bb +++ /dev/null @@ -1,27 +0,0 @@ -SUMMARY = "Compiled Swift LLVM for Linux" -HOMEPAGE = "https://github.com/apple/llvm-project" - -LICENSE="CLOSED" -LIC_FILES_CHKSUM="" - -require swift-version.inc -PV = "${SWIFT_VERSION}" - -SRC_DIR = "llvm-swift" -SRC_URI = "https://github.com/colemancda/swift-armv7/releases/download/0.4.0/llvm-swift.zip" -SRC_URI[sha256sum] = "84c21ce101c6627f07d90f10df0448d4cb2848e6e2f96e544019207467dffca7" - -inherit native - -SYSROOT_DIRS_NATIVE += "${base_prefix}/opt" -S = "${WORKDIR}/${SRC_DIR}" - -do_install_append () { - mkdir -p ${D}${base_prefix}/opt/usr/lib/llvm-swift - cp -rf ${S}/../bin ${D}${base_prefix}/opt/usr/lib/llvm-swift/ - cp -rf ${S}/../include ${D}${base_prefix}/opt/usr/lib/llvm-swift/ - cp -rf ${S}/../lib ${D}${base_prefix}/opt/usr/lib/llvm-swift/ - cp -rf ${S}/../share ${D}${base_prefix}/opt/usr/lib/llvm-swift/ -} - -FILES_${PN} += "${base_prefix}/opt/*" diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index 6278ea5..e01281e 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -1,91 +1,254 @@ -SUMMARY = "Swift standard library" -HOMEPAGE = "https://swift.org/" +SUMMARY = "Swift" +DESCRIPTION = "The Swift programming language standard library" +HOMEPAGE = "https://github.com/swiftlang/swift" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${S}/LICENSE.txt;md5=f6c482a0548ea60d6c2e015776534035" +PACKAGES:append = " ${PN}-embedded" + require swift-version.inc -PV = "${SWIFT_VERSION}" +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "swift_libdispatch_stringproc_syntax" + +SRC_URI = "\ + git://github.com/swiftlang/llvm-project.git;protocol=https;name=llvm-project;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=llvm-project; \ + git://github.com/swiftlang/swift.git;protocol=https;name=swift;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift; \ + git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;name=libdispatch;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=libdispatch; \ + git://github.com/swiftlang/swift-experimental-string-processing.git;protocol=https;name=stringproc;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-experimental-string-processing; \ + git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax; \ + " -SRC_URI = "git://github.com/apple/swift.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1 \ - file://0001-Float16.patch \ - file://fix_modulemap.sh \ - file://cmake-configure-swift-stdlib.sh \ - " -SRC_URI += "git://github.com/apple/swift-corelibs-libdispatch.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1;destsuffix=libdispatch" +S = "${WORKDIR}/swift" -S = "${WORKDIR}/git" SWIFT_BUILDDIR = "${S}/build" -DEPENDS = "gcc-runtime python3-native icu ncurses" -DEPENDS += " swift-native swift-llvm-native libgcc gcc glibc libxml2" +DEPENDS = "gcc-runtime python3-native icu ncurses swift-native libgcc gcc glibc libxml2 libxml2-native ninja-native" inherit swift-cmake-base -HOST_SWIFT_SUPPORT_DIR = "${WORKDIR}/swift-stdlib-yocto" -SWIFT_CMAKE_TOOLCHAIN_FILE = "${HOST_SWIFT_SUPPORT_DIR}/linux-${SWIFT_TARGET_ARCH}-toolchain.cmake" -SWIFT_CONFIGURE_CMAKE_SCRIPT="${WORKDIR}/cmake-configure-swift-stdlib.sh" -EXTRA_INCLUDE_FLAGS = "\ - -I${STAGING_DIR_TARGET}/usr/include/c++/current/${TARGET_SYS} \ - -I${STAGING_DIR_TARGET}/usr/include/c++/current" -TARGET_LDFLAGS += "-w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" -SWIFT_C_FLAGS = "-w -fuse-ld=lld -target ${SWIFT_TARGET_NAME} \ - --sysroot ${STAGING_DIR_TARGET} \ - -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ - -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ - ${EXTRA_INCLUDE_FLAGS}" -SWIFT_C_LINK_FLAGS = "-target ${SWIFT_TARGET_NAME} --sysroot ${STAGING_DIR_TARGET} ${EXTRA_INCLUDE_FLAGS}" +TARGET_LDFLAGS:append = " -w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" + +SWIFT_CMAKE_TOOLCHAIN_FILE = "${WORKDIR}/linux-${SWIFT_TARGET_ARCH}-toolchain.cmake" + +SWIFT_C_FLAGS = "${TARGET_CC_ARCH} -w -fuse-ld=lld -target ${SWIFT_TARGET_NAME} --sysroot ${STAGING_DIR_TARGET} -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include ${EXTRA_INCLUDE_FLAGS}" +SWIFT_C_LINK_FLAGS = "${TARGET_LD_ARCH} -target ${SWIFT_TARGET_NAME} --sysroot ${STAGING_DIR_TARGET} ${EXTRA_INCLUDE_FLAGS}" + SWIFT_CXX_FLAGS = "${SWIFT_C_FLAGS}" SWIFT_CXX_LINK_FLAGS = "${SWIFT_C_LINK_FLAGS}" +do_fix_gcc_install_dir() { + # symbolic links do not work, will not be found by Swift clang driver + # this is necessary to make the libstdc++ location heuristic work, necessary for C++ interop + (cd ${STAGING_DIR_TARGET}/usr/lib && rm -rf gcc && mkdir -p gcc && cp -rp ${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS} gcc) +} + +addtask fix_gcc_install_dir before do_configure after do_prepare_recipe_sysroot + do_configure() { - export LDFLAGS="" - export STAGING_DIR=${STAGING_DIR_TARGET} + export SDKROOT=${STAGING_DIR_TARGET} + export LLVM_SRCDIR=${WORKDIR}/llvm-project + export LLVM_BUILDDIR=${LLVM_SRCDIR}/build export SWIFT_SRCDIR=${S} - export LIBDISPATCH_SRCDIR=${WORKDIR}/libdispatch - export SWIFT_BUILDDIR="${SWIFT_BUILDDIR}" - export SWIFT_CMAKE_TOOLCHAIN_FILE=${SWIFT_CMAKE_TOOLCHAIN_FILE} - export SWIFT_NATIVE_PATH=${STAGING_DIR_NATIVE}/opt/usr/bin - export SWIFT_C_FLAGS="${SWIFT_C_FLAGS}" - export SWIFT_C_LINK_FLAGS="${SWIFT_C_LINK_FLAGS}" - export SWIFT_CXX_FLAGS="${SWIFT_CXX_FLAGS}" - export SWIFT_CXX_LINK_FLAGS="${SWIFT_CXX_LINK_FLAGS}" - export SWIFT_LLVM_DIR=${HOST_LLVM_PATH} - export CC=${STAGING_DIR_NATIVE}/opt/usr/bin/clang + export SWIFT_NATIVE_PATH=${STAGING_DIR_NATIVE}/usr/bin + export CC=${STAGING_DIR_NATIVE}/usr/bin/clang export CFLAGS="${SWIFT_C_FLAGS}" export CCLD="${SWIFT_C_LINK_FLAGS}" - export CXX=${STAGING_DIR_NATIVE}/opt/usr/bin/clang++ + export CXX=${STAGING_DIR_NATIVE}/usr/bin/clang++ export CXXFLAGS="${SWIFT_CXX_FLAGS}" - export SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH} - export SWIFT_TARGET_NAME=${SWIFT_TARGET_NAME} - mkdir -p ${HOST_SWIFT_SUPPORT_DIR} - rm -rf $SWIFT_BUILDDIR - mkdir -p $SWIFT_BUILDDIR - ${SWIFT_CONFIGURE_CMAKE_SCRIPT} + rm -rf ${LLVM_BUILDDIR} + mkdir -p ${LLVM_BUILDDIR} + + # Configure the llvm project to get the cmake files generated, so we can point + # LLVM_DIR to this folder + cmake -S ${LLVM_SRCDIR}/llvm -B ${LLVM_BUILDDIR} -G Ninja \ + -DCMAKE_INSTALL_PREFIX=${STAGING_DIR_NATIVE}/usr/lib \ + -DCMAKE_C_COMPILER=${SWIFT_NATIVE_PATH}/clang \ + -DCMAKE_CXX_COMPILER=${SWIFT_NATIVE_PATH}/clang++ \ + -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \ + -DLLVM_ENABLE_PROJECTS="llvm" \ + -DCMAKE_BUILD_TYPE=Release + + rm -rf ${SWIFT_BUILDDIR} + mkdir -p ${SWIFT_BUILDDIR} + + cat < ${SWIFT_CMAKE_TOOLCHAIN_FILE} +set(CMAKE_INSTALL_PREFIX /usr) +set(CMAKE_COLOR_MAKEFILE OFF) +set(CMAKE_CROSSCOMPILING ON) +set(CMAKE_BUILD_TYPE Release) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ${SWIFT_TARGET_ARCH}) +set(CMAKE_SYSROOT ${STAGING_DIR_TARGET}) + +set(CMAKE_C_COMPILER ${SWIFT_NATIVE_PATH}/clang) +set(CMAKE_C_COMPILER_TARGET ${TARGET_SYS}) +set(CMAKE_C_FLAGS "${SWIFT_C_FLAGS}") +set(CMAKE_C_LINK_FLAGS "${SWIFT_C_LINK_FLAGS}") + +set(CMAKE_CXX_COMPILER ${SWIFT_NATIVE_PATH}/clang++) +set(CMAKE_CXX_COMPILER_TARGET ${TARGET_SYS}) +set(CMAKE_CXX_FLAGS "${SWIFT_CXX_FLAGS}") +set(CMAKE_CXX_LINK_FLAGS "${SWIFT_CXX_LINK_FLAGS}") + +set(CMAKE_Swift_COMPILER ${SWIFT_NATIVE_PATH}/swiftc) +set(CMAKE_Swift_COMPILER_TARGET ${TARGET_SYS}) +set(CMAKE_Swift_COMPILER_WORKS ON) + +set(BUILD_DOC OFF) +set(BUILD_DOCS OFF) +set(BUILD_EXAMPLE OFF) +set(BUILD_EXAMPLES OFF) +set(BUILD_TEST OFF) +set(BUILD_TESTS OFF) +set(BUILD_TESTING OFF) +set(BUILD_SHARED_LIBS ON) + +set(LLVM_USE_LINKER lld) +set(LLVM_DIR ${LLVM_BUILDDIR}/lib/cmake/llvm) +set(LLVM_BUILD_LIBRARY_DIR ${LLVM_BUILDDIR}) +set(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN ON) + +set(SWIFT_USE_LINKER lld) +set(SWIFT_INCLUDE_TOOLS OFF) +set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER ON) +set(SWIFT_PREBUILT_CLANG ON) +set(SWIFT_NATIVE_CLANG_TOOLS_PATH ${SWIFT_NATIVE_PATH}) +set(SWIFT_NATIVE_LLVM_TOOLS_PATH ${SWIFT_NATIVE_PATH}) +set(SWIFT_NATIVE_SWIFT_TOOLS_PATH ${SWIFT_NATIVE_PATH}) +set(SWIFT_BUILD_AST_ANALYZER OFF) +set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY ON) +set(SWIFT_BUILD_DYNAMIC_STDLIB ON) +set(SWIFT_BUILD_REMOTE_MIRROR OFF) +set(SWIFT_BUILD_SOURCEKIT OFF) +set(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT OFF) +set(SWIFT_BUILD_SYNTAXPARSERLIB OFF) +set(SWIFT_ENABLE_SOURCEKIT_TESTS OFF) +set(SWIFT_INCLUDE_DOCS OFF) +set(SWIFT_INCLUDE_TOOLS OFF) +set(SWIFT_INCLUDE_TESTS OFF) +set(SWIFT_INCLUDE_TEST_BINARIES OFF) +set(SWIFT_LIBRARY_EVOLUTION 0) +set(SWIFT_RUNTIME_OS_VERSIONING OFF) +set(SWIFT_HOST_VARIANT_ARCH ${SWIFT_TARGET_ARCH}) +set(SWIFT_SDKS LINUX) +set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH ${STAGING_DIR_TARGET}) +set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY ${STAGING_DIR_TARGET}/usr/include) +set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY ${STAGING_DIR_TARGET}/usr/include) +set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N ${STAGING_DIR_TARGET}/usr/lib/libicui18n.so) +set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC ${STAGING_DIR_TARGET}/usr/lib/libicuuc.so) +set(SWIFT_PATH_TO_LIBDISPATCH_SOURCE ${WORKDIR}/libdispatch) +set(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ON) +set(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP ON) +set(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING ON) +set(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING ON) +set(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED ON) +set(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES ON) +set(SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION ON) +set(SWIFT_ENABLE_SYNCHRONIZATION ON) +set(SWIFT_PATH_TO_STRING_PROCESSING_SOURCE ${WORKDIR}/swift-experimental-string-processing) +set(SWIFT_SYNTAX_SOURCE_DIR ${WORKDIR}/swift-syntax) +set(SWIFTSYNTAX_SOURCE_DIR ${WORKDIR}/swift-syntax) +set(SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS -Xcc --gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION}/${TARGET_SYS} -no-verify-emitted-module-interface) +set(SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS "") + +set(ICU_I18N_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/libicui18n.so) +set(ICU_I18N_INCLUDE_DIRS ${STAGING_DIR_TARGET}/usr/include) +set(ICU_UC_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/libicuuc.so) +set(ICU_UC_INCLUDE_DIRS ${STAGING_DIR_TARGET}/usr/include) +set(LibRT_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/librt.a) +set(ZLIB_LIBRARY ${STAGING_DIR_TARGET}/usr/lib/libz.so) +EOF + + cmake -S ${SWIFT_SRCDIR} -B ${SWIFT_BUILDDIR} -G Ninja \ + -DSDKROOT=${STAGING_DIR_TARGET} \ + -DCMAKE_SYSROOT=${STAGING_DIR_TARGET} \ + -DCMAKE_TOOLCHAIN_FILE=${SWIFT_CMAKE_TOOLCHAIN_FILE} \ + -DSWIFT_HOST_VARIANT_ARCH=${SWIFT_TARGET_ARCH} \ + -DSWIFT_NATIVE_CLANG_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ + -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR_TARGET} \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR_TARGET}/usr/include \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY=${STAGING_DIR_TARGET}/usr/include } do_compile() { cd ${SWIFT_BUILDDIR} && ninja - # remove Swift static libs - rm -rf ${SWIFT_BUILDDIR}/lib/swift_static +} + +do_install:prepend() { # remove Dispatch (it will be built by another package) - rm -rf ${SWIFT_BUILDDIR}/lib/swift/linux/libBlocksRuntime.so - rm -rf ${SWIFT_BUILDDIR}/lib/swift/linux/libdispatch.so - rm -rf ${SWIFT_BUILDDIR}/lib/swift/linux/${SWIFT_TARGET_ARCH}/*.so - # remove some dirs from /usr/lib (we don't include them in any packages) - rm -rf ${SWIFT_BUILDDIR}/lib//swift/clang - rm -rf ${SWIFT_BUILDDIR}/lib//swift/FrameworkABIBaseline - # remove /usr/share (we don't include it in any packages) + rm -f ${SWIFT_BUILDDIR}/lib/swift/linux/libBlocksRuntime.so + rm -f ${SWIFT_BUILDDIR}/lib/swift/linux/libdispatch.so + rm -f ${SWIFT_BUILDDIR}/lib/swift/linux/${SWIFT_TARGET_ARCH}/*.so + + # remove some dirs from /lib/swift (we don't include them in any packages) + rm -rf ${SWIFT_BUILDDIR}/lib/swift/clang + rm -rf ${SWIFT_BUILDDIR}/lib/swift/FrameworkABIBaseline + + # remove /usr/share (we don't include it in any packages) rm -rf ${SWIFT_BUILDDIR}/share + # remove /usr/bin (we don't include it in any packages) rm -rf ${SWIFT_BUILDDIR}/bin } do_install() { + # install bridging and custom executor headers + install -d ${D}${includedir}/swift + install -m 0644 ${SWIFT_BUILDDIR}/include/swift/*.h ${D}${includedir}/swift + install -m 0644 ${S}/lib/ClangImporter/SwiftBridging/swift/bridging* ${D}${includedir}/swift + + # install libraries install -d ${D}${libdir} - cp -rf ${SWIFT_BUILDDIR}/lib/swift ${D}${libdir}/ + cp -rfd ${SWIFT_BUILDDIR}/lib/swift ${D}${libdir}/ } -FILES_${PN} = "${libdir}/swift/*" -INSANE_SKIP_${PN} = "file-rdeps" +FILES:${PN} = "\ + ${libdir}/swift/linux/libswift_RegexParser.so \ + ${libdir}/swift/linux/libswiftSwiftPrivateThreadExtras.so \ + ${libdir}/swift/linux/libswift_Concurrency.so \ + ${libdir}/swift/linux/libswift_Differentiation.so \ + ${libdir}/swift/linux/libswiftDifferentiationUnittest.so \ + ${libdir}/swift/linux/libswiftDistributed.so \ + ${libdir}/swift/linux/libswiftRegexBuilder.so \ + ${libdir}/swift/linux/libswiftObservation.so \ + ${libdir}/swift/linux/libswiftSwiftOnoneSupport.so \ + ${libdir}/swift/linux/libswiftSwiftPrivateLibcExtras.so \ + ${libdir}/swift/linux/libswiftRuntimeUnittest.so \ + ${libdir}/swift/linux/libswift_StringProcessing.so \ + ${libdir}/swift/linux/libswiftGlibc.so \ + ${libdir}/swift/linux/libswiftCore.so \ + ${libdir}/swift/linux/libswift_Builtin_float.so \ + ${libdir}/swift/linux/libswiftSwiftPrivate.so \ + ${libdir}/swift/linux/libswiftSynchronization.so \ + ${libdir}/swift/linux/libswiftStdlibUnittest.so \ +" + +FILES:${PN}-dev = "\ + ${includedir}/swift \ + ${libdir}/swift/shims \ + ${libdir}/swift/apinotes \ + ${libdir}/swift/linux/libswiftCommandLineSupport.a \ + ${libdir}/swift/linux/libswiftCxxStdlib.a \ + ${libdir}/swift/linux/libswiftCxx.a \ + ${libdir}/swift/linux/libcxxshim.modulemap \ + ${libdir}/swift/linux/libstdcxx.modulemap \ + ${libdir}/swift/linux/libstdcxx.h \ + ${libdir}/swift/linux/libcxxshim.h \ + ${libdir}/swift/linux/libcxxstdlibshim.h \ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH} \ + ${libdir}/swift/linux/*.swiftmodule/* \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/swift_static \ +" + +FILES:${PN}-embedded = "\ + ${libdir}/swift/embedded \ +" + +INSANE_SKIP:${PN} = "file-rdeps" + do_package_qa[noexec] = "1" diff --git a/recipes-devtools/swift/swift-stdlib/0001-Float16.patch b/recipes-devtools/swift/swift-stdlib/0001-Float16.patch deleted file mode 100644 index 56475f4..0000000 --- a/recipes-devtools/swift/swift-stdlib/0001-Float16.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 8b1dfbee0a542fe44b931f1d63bec253e320915b Mon Sep 17 00:00:00 2001 -From: Alsey Coleman Miller -Date: Fri, 11 Feb 2022 03:13:27 +0000 -Subject: [PATCH] Added Float16 patch - ---- - stdlib/public/runtime/Float16Support.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp -index 817739d4cdf..5ccd5639d67 100644 ---- a/stdlib/public/runtime/Float16Support.cpp -+++ b/stdlib/public/runtime/Float16Support.cpp -@@ -29,7 +29,7 @@ - - // Android NDK > ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_C_COMPILER $SWIFT_NATIVE_PATH/clang)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_CXX_COMPILER ${SWIFT_NATIVE_PATH}/clang++)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_C_FLAGS \"${SWIFT_C_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_C_LINK_FLAGS \"${SWIFT_C_LINK_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_CXX_FLAGS \"${SWIFT_CXX_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_CXX_LINK_FLAGS \"${SWIFT_CXX_LINK_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_USE_LINKER lld)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_USE_LINKER lld)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_DIR ${SWIFT_LLVM_DIR}/lib/cmake/llvm)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_BUILD_LIBRARY_DIR ${SWIFT_LLVM_DIR})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_TOOLS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_PREBUILT_CLANG ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_NATIVE_CLANG_TOOLS_PATH ${SWIFT_NATIVE_PATH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_NATIVE_LLVM_TOOLS_PATH ${SWIFT_NATIVE_PATH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_NATIVE_SWIFT_TOOLS_PATH ${SWIFT_NATIVE_PATH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_AST_ANALYZER OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_DYNAMIC_STDLIB ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_REMOTE_MIRROR OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_SOURCEKIT OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_SYNTAXPARSERLIB OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_REMOTE_MIRROR OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_ENABLE_SOURCEKIT_TESTS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_DOCS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_TOOLS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_TESTS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_LIBRARY_EVOLUTION 0)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_RUNTIME_OS_VERSIONING OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_HOST_VARIANT_ARCH ${SWIFT_TARGET_ARCH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDKS LINUX)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH ${STAGING_DIR} )\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY ${STAGING_DIR}/usr/include )\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY ${STAGING_DIR}/usr/include)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N ${STAGING_DIR}/usr/lib/libicui18n.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC ${STAGING_DIR}/usr/lib/libicuuc.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_I18N_LIBRARIES ${STAGING_DIR}/usr/lib/libicui18n.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_I18N_INCLUDE_DIRS ${STAGING_DIR}/usr/include)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_UC_LIBRARIES ${STAGING_DIR}/usr/lib/libicuuc.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_UC_INCLUDE_DIRS ${STAGING_DIR}/usr/include)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LibRT_LIBRARIES ${STAGING_DIR}/usr/lib/librt.a)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ZLIB_LIBRARY ${STAGING_DIR}/usr/lib/libz.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_PATH_TO_LIBDISPATCH_SOURCE ${LIBDISPATCH_SRCDIR})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - -echo "Configure Swift" -cmake -S $SWIFT_SRCDIR -B $SWIFT_BUILDDIR -G Ninja \ - -DCMAKE_INSTALL_PREFIX="/usr" \ - -DCMAKE_COLOR_MAKEFILE=OFF \ - -DBUILD_DOC=OFF \ - -DBUILD_DOCS=OFF \ - -DBUILD_EXAMPLE=OFF \ - -DBUILD_EXAMPLES=OFF \ - -DBUILD_TEST=OFF \ - -DBUILD_TESTS=OFF \ - -DBUILD_TESTING=OFF \ - -DBUILD_SHARED_LIBS=ON \ - -DCMAKE_CROSSCOMPILING=ON \ - -DCMAKE_TOOLCHAIN_FILE=$SWIFT_CMAKE_TOOLCHAIN_FILE \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER=${SWIFT_NATIVE_PATH}/clang \ - -DCMAKE_CXX_COMPILER=${SWIFT_NATIVE_PATH}/clang++ \ - -DCMAKE_C_FLAGS="${SWIFT_C_FLAGS}" \ - -DCMAKE_C_LINK_FLAGS="${SWIFT_C_LINK_FLAGS}" \ - -DCMAKE_CXX_FLAGS="${SWIFT_CXX_FLAGS}" \ - -DCMAKE_CXX_LINK_FLAGS="${SWIFT_CXX_LINK_FLAGS}" \ - -DSWIFT_USE_LINKER=lld \ - -DLLVM_USE_LINKER=lld \ - -DLLVM_DIR=${SWIFT_LLVM_DIR}/lib/cmake/llvm \ - -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ - -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=ON \ - -DSWIFT_NATIVE_CLANG_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ - -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ - -DSWIFT_BUILD_AST_ANALYZER=OFF \ - -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=ON \ - -DSWIFT_BUILD_DYNAMIC_STDLIB=ON \ - -DSWIFT_BUILD_REMOTE_MIRROR=OFF \ - -DSWIFT_BUILD_SOURCEKIT=OFF \ - -DSWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT=OFF \ - -DSWIFT_BUILD_SYNTAXPARSERLIB=OFF \ - -DSWIFT_BUILD_REMOTE_MIRROR=OFF \ - -DSWIFT_ENABLE_SOURCEKIT_TESTS=OFF \ - -DSWIFT_INCLUDE_DOCS=OFF \ - -DSWIFT_INCLUDE_TOOLS=OFF \ - -DSWIFT_INCLUDE_TESTS=OFF \ - -DSWIFT_LIBRARY_EVOLUTION=0 \ - -DSWIFT_RUNTIME_OS_VERSIONING=OFF \ - -DSWIFT_HOST_VARIANT_ARCH=$SWIFT_TARGET_ARCH \ - -DSWIFT_SDKS=LINUX \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR} \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \ - -DSWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N=${STAGING_DIR}/usr/lib/libicui18n.so \ - -DSWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC=${STAGING_DIR}/usr/lib/libicuuc.so \ - -DICU_I18N_LIBRARIES=${STAGING_DIR}/usr/lib/libicui18n.so \ - -DICU_I18N_INCLUDE_DIRS=${STAGING_DIR}/usr/include \ - -DICU_UC_LIBRARIES=${STAGING_DIR}/usr/lib/libicuuc.so \ - -DICU_UC_INCLUDE_DIRS=${STAGING_DIR}/usr/include \ diff --git a/recipes-devtools/swift/swift-stdlib/fix_modulemap.sh b/recipes-devtools/swift/swift-stdlib/fix_modulemap.sh deleted file mode 100755 index e831c3a..0000000 --- a/recipes-devtools/swift/swift-stdlib/fix_modulemap.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -# See https://github.com/CSCIX65G/SwiftCrossCompilers/blob/master/build_cross_compiler#L34 -# This is a funny function. The Glibc.modulemap contains absolute include -# pathes like so: -# header "/usr/include/aarch64-linux-gnu/sys/ioctl.h" -# This thing creates a new directory: -# ${ARCH_NAME}-swift.xctoolchain/usr/lib/swift/linux/aarch64/private_includes -# and for each header in the modmap it creates a shim header which includes -# a relative path, like: -# ${ARCH_NAME}-swift.xctoolchain/usr/lib/swift/linux/aarch64/private_includes/aarch64-linux-gnu_sys_ioctl.h -# which includes: -# #include -function fix_glibc_modulemap() { - local glc_mm - local tmp - local inc_dir - - glc_mm="$1" - if ! test -f "$glc_mm"; then - echo "Missing: $glc_mm" - exit 42 - fi - - echo "step 1: $glc_mm" - - tmp=$(mktemp "$glc_mm"_orig_XXXXXX) - echo "step 2: $tmp" - inc_dir="$(dirname "$glc_mm")/private_includes" - echo "step 3: $inc_dir" - cat "$glc_mm" >>"$tmp" - echo -n >"$glc_mm" - rm -rf "$inc_dir" - mkdir "$inc_dir" - cat "$tmp" | while IFS='' read line; do - # hh: apparently the modmap started w/ two slashes? ///usr/local/ - # if [[ "$line" =~ ^(\ *header\ )\"\/\/\/usr\/include\/(${TC_TARGET}\/)?([^\"]+)\" ]]; then - if [[ "$line" =~ ^(\ *header\ )\"\/usr\/include\/(${TC_TARGET}\/)?([^\"]+)\" ]]; then - local orig_inc - local rel_repl_inc - local repl_inc - - orig_inc="${BASH_REMATCH[3]}" - rel_repl_inc="$(echo "$orig_inc" | tr / _)" - repl_inc="$inc_dir/$rel_repl_inc" - echo "${BASH_REMATCH[1]} \"$(basename "$inc_dir")/$rel_repl_inc\"" >>"$glc_mm" - if [[ "$orig_inc" == "uuid/uuid.h" ]]; then - # no idea why ;) - echo "#include " >>"$repl_inc" - elif [[ $orig_inc == *"gnueabi"* ]]; then - echo "#include <${orig_inc#*/}>" >>"$repl_inc" - else - echo "#include <$orig_inc>" >>"$repl_inc" - fi - true - else - echo "$line" >>"$glc_mm" - fi - done -} - - -fix_glibc_modulemap $1 From ce1a99e7af7c898398d1744b1f6568ac37d2443d Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:48:33 +1000 Subject: [PATCH 16/41] swift-testing: add support --- recipes-devtools/swift/swift-testing.bb | 41 +++++++++++++++++++ .../0001-build-as-dynamic-library.patch | 35 ++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 recipes-devtools/swift/swift-testing.bb create mode 100644 recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch diff --git a/recipes-devtools/swift/swift-testing.bb b/recipes-devtools/swift/swift-testing.bb new file mode 100644 index 0000000..3ef267c --- /dev/null +++ b/recipes-devtools/swift/swift-testing.bb @@ -0,0 +1,41 @@ +SUMMARY = "swift-testing" +DESCRIPTION = "A package with expressive and intuitive APIs that make testing your Swift code a breeze." +HOMEPAGE = "https://github.com/swiftlang/swift-testing" + +SWIFT_BUILD_TESTS = "0" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9426349f482bb39d6a4a080793545176" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "swift_testing" + +SRC_URI = "git://github.com/swiftlang/swift-testing.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" +SRC_URI += "file://0001-build-as-dynamic-library.patch;striplevel=1;" + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +inherit swift + +do_install() { + install -d ${D}${libdir}/swift/linux + + install -m 0644 ${BUILD_DIR}/libTesting.so ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/Testing.swiftmodule ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/Testing.swiftdoc ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/Testing.swiftinterface ${D}${libdir}/swift/linux + + rm -f ${BUILD_DIR}/Modules/*.swiftsourceinfo +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libTesting.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/linux/Testing.swiftmodule \ + ${libdir}/swift/linux/Testing.swiftdoc \ + ${libdir}/swift/linux/Testing.swiftinterface \ +" diff --git a/recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch b/recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch new file mode 100644 index 0000000..dd218ec --- /dev/null +++ b/recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch @@ -0,0 +1,35 @@ +From 150381e5bda561daa70b53aee1f222254bb4cf00 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Mon, 17 Mar 2025 10:14:02 +1100 +Subject: [PATCH] build as dynamic library + +--- + Package.swift | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Package.swift b/Package.swift +index c498b59..7065f6f 100644 +--- a/Package.swift ++++ b/Package.swift +@@ -28,6 +28,7 @@ let package = Package( + products: [ + .library( + name: "Testing", ++ type: .dynamic, + targets: ["Testing"] + ), + ], +@@ -45,7 +46,9 @@ let package = Package( + ], + exclude: ["CMakeLists.txt"], + cxxSettings: .packageSettings, +- swiftSettings: .packageSettings ++ swiftSettings: .packageSettings + [ ++ .unsafeFlags(["-enable-library-evolution", "-emit-module-interface", "-emit-module-interface-path", "Testing.swiftinterface"]) ++ ] + ), + .testTarget( + name: "TestingTests", +-- +2.43.0 + From abf3127b0897f2c95de18b3385ea69d7b2beedff Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:48:41 +1000 Subject: [PATCH 17/41] swift-xctest: add support --- recipes-devtools/swift/swift-xctest.bb | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 recipes-devtools/swift/swift-xctest.bb diff --git a/recipes-devtools/swift/swift-xctest.bb b/recipes-devtools/swift/swift-xctest.bb new file mode 100644 index 0000000..f7ff4ea --- /dev/null +++ b/recipes-devtools/swift/swift-xctest.bb @@ -0,0 +1,39 @@ +SUMMARY = "swift-xctest" +DESCRIPTION = "A common framework for writing unit tests in Swift." +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-xctest" + +SWIFT_BUILD_TESTS = "0" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" + +SRC_URI = "git://github.com/swiftlang/swift-corelibs-xctest.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +inherit swift + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" + +do_install() { + install -d ${D}${libdir}/swift/linux + + install -m 0755 ${BUILD_DIR}/libXCTest.so ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/XCTest.swiftmodule ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/XCTest.swiftdoc ${D}${libdir}/swift/linux + + rm -f ${BUILD_DIR}/Modules/XCTest.swiftsourceinfo +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libXCTest.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/linux/XCTest.swiftmodule \ + ${libdir}/swift/linux/XCTest.swiftdoc \ +" From eef9d156b3e993c8e8fdc434042de8d5e7ec9178 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:32:01 +1000 Subject: [PATCH 18/41] add SWIFT_BUILD_TESTS option for building Swift test packages Add a SWIFT_BUILD_TESTS option to enable building tests, defaults to DEBUG_BUILD. --- classes/swift.bbclass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/swift.bbclass b/classes/swift.bbclass index d5c8da9..e4a7ddd 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -1,7 +1,10 @@ # avoid conflicts with meta-clang TOOLCHAIN = "gcc" -DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch libfoundation" +SWIFT_BUILD_TESTS ?= "${DEBUG_BUILD}" + +DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch swift-foundation" +DEPENDS += "${@oe.utils.conditional('SWIFT_BUILD_TESTS', '1', 'swift-xctest swift-testing', '', d)}" # Default build directory for SPM is "./.build" # (see 'swift [build|package|run|test] --help') From 108af05a64c87f1947c578722671b05736cb7234 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:42:56 +1000 Subject: [PATCH 19/41] consolidate tests into single swift-hello-world test This exercises the test and C++ interop package and feature, respectively --- .../swift-hello-world/files/Package.swift | 14 ++++++++++--- .../files/Sources/hello-world/main.swift | 3 ++- .../hello-world-test/hello-world-test.swift | 8 +++++++ .../swift-hello-world/swift-hello-world.bb | 21 ++++++++++++++++--- recipes-test/swift/swift-build-test.bb | 9 -------- .../swift/swift-build-test/Package.swift | 19 ----------------- .../Sources/hello-world/main.swift | 4 ---- recipes-test/swift/swift-cmake-test.bb | 12 ----------- .../swift/swift-cmake-test/CMakeLists.txt | 8 ------- .../swift/swift-cmake-test/main.swift | 4 ---- 10 files changed, 39 insertions(+), 63 deletions(-) create mode 100644 recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift delete mode 100644 recipes-test/swift/swift-build-test.bb delete mode 100644 recipes-test/swift/swift-build-test/Package.swift delete mode 100644 recipes-test/swift/swift-build-test/Sources/hello-world/main.swift delete mode 100644 recipes-test/swift/swift-cmake-test.bb delete mode 100644 recipes-test/swift/swift-cmake-test/CMakeLists.txt delete mode 100644 recipes-test/swift/swift-cmake-test/main.swift diff --git a/recipes-test/swift-hello-world/files/Package.swift b/recipes-test/swift-hello-world/files/Package.swift index be660c9..c106ba8 100644 --- a/recipes-test/swift-hello-world/files/Package.swift +++ b/recipes-test/swift-hello-world/files/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.6 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -12,8 +12,16 @@ let package = Package( targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. - .target( + .executableTarget( name: "hello-world", - dependencies: []) + dependencies: [], + swiftSettings: [ + .swiftLanguageMode(.v5), + .interoperabilityMode(.Cxx), + ] + ), + .testTarget( + name: "hello-world-test", + dependencies: []), ] ) diff --git a/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift b/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift index 14f6d40..c65c8ed 100644 --- a/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift +++ b/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift @@ -1,10 +1,11 @@ import Foundation import Dispatch import Glibc +import CxxStdlib func main() async throws { print("Hello, world! 👋") - try await Task.sleep(1_000_000_000) + try await Task.sleep(for: .seconds(1)) print("User: \(ProcessInfo.processInfo.fullUserName)") let dateFormatter = DateFormatter() dateFormatter.dateStyle = .full diff --git a/recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift b/recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift new file mode 100644 index 0000000..807c3ad --- /dev/null +++ b/recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift @@ -0,0 +1,8 @@ +import XCTest +import Testing + +final class TestTest: XCTestCase { + func testSomething() { + XCTAssertEqual(true, true) + } +} diff --git a/recipes-test/swift-hello-world/swift-hello-world.bb b/recipes-test/swift-hello-world/swift-hello-world.bb index 77a0fc1..15fb6ae 100644 --- a/recipes-test/swift-hello-world/swift-hello-world.bb +++ b/recipes-test/swift-hello-world/swift-hello-world.bb @@ -1,8 +1,23 @@ -DESCRIPTION = "swift 5.6.1 test application" +DESCRIPTION = "Swift Hello World!" LICENSE = "CLOSED" -SRC_URI = "file://Sources/hello-world/main.swift \ - file://Package.swift \ +SWIFT_BUILD_TESTS = "1" + +RDEPENDS:${PN} += "swift-xctest swift-testing" + +SRC_URI = "\ + file://Package.swift \ + file://Sources \ + file://Tests \ " +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + inherit swift + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${BUILD_DIR}/hello-world ${D}${bindir} + install -m 0755 ${BUILD_DIR}/hello-worldPackageTests.xctest ${D}${bindir} +} diff --git a/recipes-test/swift/swift-build-test.bb b/recipes-test/swift/swift-build-test.bb deleted file mode 100644 index 1fc6c1c..0000000 --- a/recipes-test/swift/swift-build-test.bb +++ /dev/null @@ -1,9 +0,0 @@ -DESCRIPTION = "swift 5.1.2 test application" -LICENSE = "CLOSED" - -SRC_URI = "file://Sources/hello-world/main.swift \ - file://Package.swift \ -" - -inherit swift - diff --git a/recipes-test/swift/swift-build-test/Package.swift b/recipes-test/swift/swift-build-test/Package.swift deleted file mode 100644 index 43e8841..0000000 --- a/recipes-test/swift/swift-build-test/Package.swift +++ /dev/null @@ -1,19 +0,0 @@ -// swift-tools-version:5.1 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "hello-world", - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages which this package depends on. - .target( - name: "hello-world", - dependencies: []) - ] -) diff --git a/recipes-test/swift/swift-build-test/Sources/hello-world/main.swift b/recipes-test/swift/swift-build-test/Sources/hello-world/main.swift deleted file mode 100644 index a43bbc4..0000000 --- a/recipes-test/swift/swift-build-test/Sources/hello-world/main.swift +++ /dev/null @@ -1,4 +0,0 @@ -import Dispatch -import Foundation - -print("Hello, world!") diff --git a/recipes-test/swift/swift-cmake-test.bb b/recipes-test/swift/swift-cmake-test.bb deleted file mode 100644 index d9a15fc..0000000 --- a/recipes-test/swift/swift-cmake-test.bb +++ /dev/null @@ -1,12 +0,0 @@ -SUMMARY = "Swift standard library testing package" - -LICENSE = "CLOSED" - -SRC_URI = "file://main.swift \ - file://CMakeLists.txt \ -" - -inherit swift-cmake - -S = "${WORKDIR}" - diff --git a/recipes-test/swift/swift-cmake-test/CMakeLists.txt b/recipes-test/swift/swift-cmake-test/CMakeLists.txt deleted file mode 100644 index 3b3266a..0000000 --- a/recipes-test/swift/swift-cmake-test/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.16.3) - -project(HelloWorld - LANGUAGES C Swift) - -add_executable(hello main.swift) - -install(TARGETS hello RUNTIME DESTINATION bin) diff --git a/recipes-test/swift/swift-cmake-test/main.swift b/recipes-test/swift/swift-cmake-test/main.swift deleted file mode 100644 index b01292c..0000000 --- a/recipes-test/swift/swift-cmake-test/main.swift +++ /dev/null @@ -1,4 +0,0 @@ -import Dispatch -import Foundation - -print("hello world") From 60c2569065974fdd3ad021922fd4aac67b0a0e07 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 22 Jun 2025 15:19:15 -0400 Subject: [PATCH 20/41] fix do_fix_gcc_install_dir typos - SWIFT_TARGET_ARCH cannot be used since the arch in the sysroot may likely be different. - Looks like pointing to `-oe-linux` was another typo as well in swift.bbclass. --- classes/swift.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/swift.bbclass b/classes/swift.bbclass index e4a7ddd..95c2b50 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -26,7 +26,7 @@ SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aar do_fix_gcc_install_dir() { # symbolic links do not work, will not be found by Swift clang driver # this is necessary to make the libstdc++ location heuristic work, necessary for C++ interop - (cd ${STAGING_DIR_TARGET}/usr/lib && rm -rf gcc && mkdir -p gcc && cp -rp ${SWIFT_TARGET_ARCH}-oe-linux gcc) + (cd ${STAGING_DIR_TARGET}/usr/lib && rm -rf gcc && mkdir -p gcc && cp -rp ${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS} gcc) } addtask fix_gcc_install_dir before do_configure after do_prepare_recipe_sysroot From a7b9c99d32035bd3a8995931444e710f774a9bb0 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 24 Jun 2025 10:45:22 +1000 Subject: [PATCH 21/41] update in-tree CMake to match Scarthgap (3.28.3) Swift 6.x requires CMake 3.24 or higher. --- ...ative_3.22.3.bb => cmake-native_3.28.3.bb} | 16 ++-- recipes-devtools/cmake/cmake.inc | 12 +-- ...mpilerABI-Strip-pipe-from-compile-fl.patch | 8 +- ...stem-use-oe-environment-vars-to-load.patch | 44 ----------- ...1-CMakeLists.txt-disable-USE_NGHTTP2.patch | 35 ++++++++ ...t-OpenEmbedded-Qt4-tool-binary-names.patch | 56 ------------- ...-if-system-Qt-installation-is-broken.patch | 79 ------------------- .../cmake/cmake/environment.d-cmake.sh | 2 +- .../{cmake_3.22.3.bb => cmake_3.28.3.bb} | 7 +- 9 files changed, 57 insertions(+), 202 deletions(-) rename recipes-devtools/cmake/{cmake-native_3.22.3.bb => cmake-native_3.28.3.bb} (75%) delete mode 100644 recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch create mode 100644 recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch delete mode 100644 recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch delete mode 100644 recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch rename recipes-devtools/cmake/{cmake_3.22.3.bb => cmake_3.28.3.bb} (90%) diff --git a/recipes-devtools/cmake/cmake-native_3.22.3.bb b/recipes-devtools/cmake/cmake-native_3.28.3.bb similarity index 75% rename from recipes-devtools/cmake/cmake-native_3.22.3.bb rename to recipes-devtools/cmake/cmake-native_3.28.3.bb index 45ea78a..546d117 100644 --- a/recipes-devtools/cmake/cmake-native_3.22.3.bb +++ b/recipes-devtools/cmake/cmake-native_3.28.3.bb @@ -1,21 +1,22 @@ require cmake.inc inherit native -DEPENDS += "bzip2-replacement-native xz-native zlib-native curl-native ncurses-native zstd-native" +DEPENDS += "bzip2-replacement-native xz-native zlib-native ncurses-native zstd-native openssl-native" SRC_URI += "file://OEToolchainConfig.cmake \ file://environment.d-cmake.sh \ - file://0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch \ file://0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch \ + file://0001-CMakeLists.txt-disable-USE_NGHTTP2.patch \ " -LICENSE:append = " & BSD-1-Clause & MIT & BSD-2-Clause" +LICENSE:append = " & BSD-1-Clause & MIT & BSD-2-Clause & curl" LIC_FILES_CHKSUM:append = " \ - file://Utilities/cmjsoncpp/LICENSE;md5=fa2a23dd1dc6c139f35105379d76df2b \ + file://Utilities/cmjsoncpp/LICENSE;md5=5d73c165a0f9e86a1342f32d19ec5926 \ file://Utilities/cmlibarchive/COPYING;md5=d499814247adaee08d88080841cb5665 \ file://Utilities/cmexpat/COPYING;md5=9e2ce3b3c4c0f2670883a23bbd7c37a9 \ file://Utilities/cmlibrhash/COPYING;md5=a8c2a557a5c53b1c12cddbee98c099af \ - file://Utilities/cmlibuv/LICENSE;md5=a68902a430e32200263d182d44924d47 \ + file://Utilities/cmlibuv/LICENSE;md5=ad93ca1fffe931537fcf64f6fcce084d \ + file://Utilities/cmcurl/COPYING;md5=db8448a1e43eb2125f7740fc397db1f6 \ " B = "${WORKDIR}/build" @@ -26,17 +27,18 @@ CMAKE_EXTRACONF = "\ -DBUILD_CursesDialog=1 \ -DCMAKE_USE_SYSTEM_LIBRARIES=1 \ -DCMAKE_USE_SYSTEM_LIBRARY_JSONCPP=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_CPPDAP=0 \ -DCMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE=0 \ -DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=0 \ -DCMAKE_USE_SYSTEM_LIBRARY_LIBRHASH=0 \ -DCMAKE_USE_SYSTEM_LIBRARY_EXPAT=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_CURL=0 \ -DENABLE_ACL=0 -DHAVE_ACL_LIBACL_H=0 \ -DHAVE_SYS_ACL_H=0 \ - -DCURL_LIBRARIES=-lcurl \ " do_configure () { - ${S}/configure --verbose --prefix=${prefix} \ + ${S}/bootstrap --verbose --prefix=${prefix} \ ${@oe.utils.parallel_make_argument(d, '--parallel=%d')} \ ${@bb.utils.contains('CCACHE', 'ccache ', '--enable-ccache', '', d)} \ -- ${CMAKE_EXTRACONF} diff --git a/recipes-devtools/cmake/cmake.inc b/recipes-devtools/cmake/cmake.inc index 3811aae..a52506a 100644 --- a/recipes-devtools/cmake/cmake.inc +++ b/recipes-devtools/cmake/cmake.inc @@ -10,7 +10,7 @@ HOMEPAGE = "http://www.cmake.org/" BUGTRACKER = "http://public.kitware.com/Bug/my_view_page.php" SECTION = "console/utils" LICENSE = "BSD-3-Clause" -LIC_FILES_CHKSUM = "file://Copyright.txt;md5=31023e1d3f51ca90a58f55bcee8e2339 \ +LIC_FILES_CHKSUM = "file://Copyright.txt;md5=9d3d12c5f3b4c1f83650adcc65b59c06 \ file://Source/cmake.h;beginline=1;endline=2;md5=a5f70e1fef8614734eae0d62b4f5891b \ " @@ -18,14 +18,10 @@ CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \ file://0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch \ - file://0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch \ - file://0004-Fail-silently-if-system-Qt-installation-is-broken.patch \ -" + " -SRC_URI[sha256sum] = "9f8469166f94553b6978a16ee29227ec49a2eb5ceb608275dec40d8ae0d1b5a0" +SRC_URI[sha256sum] = "72b7570e5c8593de6ac4ab433b73eab18c5fb328880460c86ce32608141ad5c1" UPSTREAM_CHECK_REGEX = "cmake-(?P\d+(\.\d+)+)\.tar" -# This is specific to the npm package that installs cmake, so isn't -# relevant to OpenEmbedded -CVE_CHECK_IGNORE += "CVE-2016-10642" +CVE_STATUS[CVE-2016-10642] = "cpe-incorrect: This is specific to the npm package that installs cmake, so isn't relevant to OpenEmbedded" diff --git a/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch b/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch index a302734..7ffcc95 100644 --- a/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch +++ b/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch @@ -1,4 +1,4 @@ -From dab7ba34f87be0172f6586325656ee962de0029e Mon Sep 17 00:00:00 2001 +From bd94bbdc35a9da4c73d538e0cc55bc95944f620d Mon Sep 17 00:00:00 2001 From: Philip Lorenz Date: Mon, 3 Jun 2024 13:19:24 +0200 Subject: [PATCH] CMakeDetermineCompilerABI: Strip -pipe from compile flags @@ -35,13 +35,13 @@ Signed-off-by: Philip Lorenz 1 file changed, 5 insertions(+) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake -index 8191d819bf..ae4c9ee44e 100644 +index efc18f93c2..f2e40479b1 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake -@@ -35,6 +35,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) +@@ -43,6 +43,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # Avoid failing ABI detection on warnings. - string(REGEX REPLACE "(^| )-Werror([= ][^ ]*)?( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") + string(REGEX REPLACE "(^| )-Werror([= ][^-][^ ]*)?( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") + # Avoid passing of "-pipe" when determining the compiler internals. With + # "-pipe" GCC will use pipes to pass data between the involved + # executables. This may lead to issues when their stderr output (which diff --git a/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch b/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch deleted file mode 100644 index 9a2287f..0000000 --- a/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 89f6c846f02ad6d30b9ebb7eaaaa4fb6f9cec054 Mon Sep 17 00:00:00 2001 -From: Cody P Schafer -Date: Thu, 27 Apr 2017 11:35:05 -0400 -Subject: [PATCH] CMakeDetermineSystem: use oe environment vars to load default - toolchain file in sdk - -Passing the toolchain by: - - - shell aliases does not work if cmake is called by a script - - unconditionally by a wrapper script causes cmake to believe it is - configuring things when it is not (for example, `cmake --build` breaks). - -The OE_CMAKE_TOOLCHAIN_FILE variable is only used as a default if no -toolchain is explicitly specified. - -Setting the CMAKE_TOOLCHAIN_FILE cmake variable is marked as cached -because '-D' options are cache entries themselves. - -Upstream-Status: Inappropriate [oe-core specific] -Signed-off-by: Cody P Schafer -Signed-off-by: Otavio Salvador - ---- - Modules/CMakeDetermineSystem.cmake | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake -index 8c7af067..ade2b189 100644 ---- a/Modules/CMakeDetermineSystem.cmake -+++ b/Modules/CMakeDetermineSystem.cmake -@@ -112,6 +112,13 @@ else() - endif() - endif() - -+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) -+ if(DEFINED ENV{OE_CMAKE_TOOLCHAIN_FILE}) -+ set(CMAKE_TOOLCHAIN_FILE "$ENV{OE_CMAKE_TOOLCHAIN_FILE}" CACHE FILEPATH "toolchain file") -+ message(STATUS "Toolchain file defaulted to '${CMAKE_TOOLCHAIN_FILE}'") -+ endif() -+endif() -+ - # if a toolchain file is used, the user wants to cross compile. - # in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_* - # variables around so they can be used in CMakeLists.txt. diff --git a/recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch b/recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch new file mode 100644 index 0000000..b2933d8 --- /dev/null +++ b/recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch @@ -0,0 +1,35 @@ +From d33d8a5e9f3b25a80d47b72b1a8a6624a85563c1 Mon Sep 17 00:00:00 2001 +From: Changqing Li +Date: Wed, 28 Dec 2022 17:51:27 +0800 +Subject: [PATCH] CMakeLists.txt: disable USE_NGHTTP2 + +nghttp2 depends on cmake-native to build, to break circular +dependency, disable nghttp2. + +Upstream-Status: Inappropriate [oe specific] + +Signed-off-by: Changqing Li + +Adjust the patch to apply on top of v3.28.3. + +Signed-off-by: Trevor Gamblin +--- + Utilities/cmcurl/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt +index 9387247366..d3de01f4e8 100644 +--- a/Utilities/cmcurl/CMakeLists.txt ++++ b/Utilities/cmcurl/CMakeLists.txt +@@ -88,7 +88,7 @@ set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only") + set(PICKY_COMPILER OFF CACHE INTERNAL "Enable picky compiler options") + set(SHARE_LIB_OBJECT OFF) + set(USE_LIBIDN2 ON) +-set(USE_NGHTTP2 ON) ++set(USE_NGHTTP2 OFF) + set(USE_NGTCP2 OFF) + set(USE_QUICHE OFF) + set(USE_WIN32_IDN OFF) +-- +2.43.0 + diff --git a/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch b/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch deleted file mode 100644 index 575a5cb..0000000 --- a/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 2d02ac91d5a5d72eaddba4894eaa6db3ed8fee62 Mon Sep 17 00:00:00 2001 -From: Otavio Salvador -Date: Thu, 12 May 2011 15:36:03 +0000 -Subject: [PATCH] cmake: support OpenEmbedded Qt4 tool binary names - -The FindQt4 module looks for Qt4 binaries to be able to gather the -paths used for compilation and also to be using during other processes -(translation update, translation binary generating and like) however -OpenEmbedded has renamed those to allow old QMake to be used in -parallel with the current one. This patch adds support for the -OpenEmbedded specific binary names. - -Upstream-Status: Inappropriate [embedded specific] - -Signed-off-by: Otavio Salvador - -The patch was slightly adapted in order to match cmake 3.2.2: -Instead of find_program, _find_qt4_program is now used. - -Signed-off-by: Moritz Blume -Signed-off-by: Otavio Salvador - ---- - Modules/FindQt4.cmake | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake -index 3993968..b2a8585 100644 ---- a/Modules/FindQt4.cmake -+++ b/Modules/FindQt4.cmake -@@ -518,7 +518,7 @@ endfunction() - - set(QT4_INSTALLED_VERSION_TOO_OLD FALSE) - --set(_QT4_QMAKE_NAMES qmake qmake4 qmake-qt4 qmake-mac) -+set(_QT4_QMAKE_NAMES qmake qmake2 qmake4 qmake-qt4 qmake-mac) - _qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION) - - if (QT_QMAKE_EXECUTABLE AND -@@ -1136,12 +1136,12 @@ if (QT_QMAKE_EXECUTABLE AND - _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc4 moc) - _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic4 uic) - _find_qt4_program(QT_UIC3_EXECUTABLE Qt4::uic3 uic3) -- _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc) -- _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml) -- _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp) -+ _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc4 rcc) -+ _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml4 qdbuscpp2xml) -+ _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp4 qdbusxml2cpp) - _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate4 lupdate) - _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease4 lrelease) -- _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator) -+ _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator qcollectiongenerator4) - _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer4 designer) - _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist4 linguist) - diff --git a/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch b/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch deleted file mode 100644 index 1b196db..0000000 --- a/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 60864efbe52cc12018efaafbc4e4c3c8b4af2b65 Mon Sep 17 00:00:00 2001 -From: Otavio Salvador -Date: Thu, 5 Jul 2018 10:26:48 -0300 -Subject: [PATCH] Fail silently if system Qt installation is broken - -Fixes a regression in behaviour from 2.8.10 to 2.8.11 resulting in the -following error if the system Qt installation is broken: - -CMake Error at Modules/FindQt4.cmake:1028 (set_property): - set_property could not find TARGET Qt4::QtCore. Perhaps it has not yet - been created. -Call Stack (most recent call first): - Tests/RunCMake/CMakeLists.txt:79 (find_package) - -Upstream-Status: Pending - -Signed-off-by: Paul Eggleton - -The patch was slightly adapted in order to match cmake 3.2.2: -Another set_property was introduced which had to be included -within the if(QT_QTCORE_FOUND) statement. - -Signed-off-by: Moritz Blume -Signed-off-by: Otavio Salvador - ---- - Modules/FindQt4.cmake | 39 ++++++++++++++++++++------------------- - 1 file changed, 20 insertions(+), 19 deletions(-) - -diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake -index b2a8585..77c89aa 100644 ---- a/Modules/FindQt4.cmake -+++ b/Modules/FindQt4.cmake -@@ -988,25 +988,26 @@ if (QT_QMAKE_EXECUTABLE AND - endif() - endmacro() - -- -- # Set QT_xyz_LIBRARY variable and add -- # library include path to QT_INCLUDES -- _QT4_ADJUST_LIB_VARS(QtCore) -- set_property(TARGET Qt4::QtCore APPEND PROPERTY -- INTERFACE_INCLUDE_DIRECTORIES -- "${QT_MKSPECS_DIR}/default" -- ${QT_INCLUDE_DIR} -- ) -- set_property(TARGET Qt4::QtCore APPEND PROPERTY -- INTERFACE_COMPILE_DEFINITIONS -- $<$>:QT_NO_DEBUG> -- ) -- set_property(TARGET Qt4::QtCore PROPERTY -- INTERFACE_QT_MAJOR_VERSION 4 -- ) -- set_property(TARGET Qt4::QtCore APPEND PROPERTY -- COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION -- ) -+ if(QT_QTCORE_FOUND) -+ # Set QT_xyz_LIBRARY variable and add -+ # library include path to QT_INCLUDES -+ _QT4_ADJUST_LIB_VARS(QtCore) -+ set_property(TARGET Qt4::QtCore APPEND PROPERTY -+ INTERFACE_INCLUDE_DIRECTORIES -+ "${QT_MKSPECS_DIR}/default" -+ ${QT_INCLUDE_DIR} -+ ) -+ set_property(TARGET Qt4::QtCore APPEND PROPERTY -+ INTERFACE_COMPILE_DEFINITIONS -+ $<$>:QT_NO_DEBUG> -+ ) -+ set_property(TARGET Qt4::QtCore PROPERTY -+ INTERFACE_QT_MAJOR_VERSION 4 -+ ) -+ set_property(TARGET Qt4::QtCore APPEND PROPERTY -+ COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION -+ ) -+ endif() - - foreach(QT_MODULE ${QT_MODULES}) - _QT4_ADJUST_LIB_VARS(${QT_MODULE}) diff --git a/recipes-devtools/cmake/cmake/environment.d-cmake.sh b/recipes-devtools/cmake/cmake/environment.d-cmake.sh index 7bdb19f..c94b6bb 100644 --- a/recipes-devtools/cmake/cmake/environment.d-cmake.sh +++ b/recipes-devtools/cmake/cmake/environment.d-cmake.sh @@ -1,2 +1,2 @@ -export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" +export CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`" diff --git a/recipes-devtools/cmake/cmake_3.22.3.bb b/recipes-devtools/cmake/cmake_3.28.3.bb similarity index 90% rename from recipes-devtools/cmake/cmake_3.22.3.bb rename to recipes-devtools/cmake/cmake_3.28.3.bb index 752c37b..6a9a326 100644 --- a/recipes-devtools/cmake/cmake_3.22.3.bb +++ b/recipes-devtools/cmake/cmake_3.28.3.bb @@ -9,14 +9,13 @@ SRC_URI:append:class-nativesdk = " \ file://SDKToolchainConfig.cmake.template \ file://cmake-setup.py \ file://environment.d-cmake.sh \ - file://0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch \ " LICENSE:append = " & BSD-1-Clause & MIT" LIC_FILES_CHKSUM:append = " \ - file://Utilities/cmjsoncpp/LICENSE;md5=fa2a23dd1dc6c139f35105379d76df2b \ + file://Utilities/cmjsoncpp/LICENSE;md5=5d73c165a0f9e86a1342f32d19ec5926 \ file://Utilities/cmlibrhash/COPYING;md5=a8c2a557a5c53b1c12cddbee98c099af \ - file://Utilities/cmlibuv/LICENSE;md5=a68902a430e32200263d182d44924d47 \ + file://Utilities/cmlibuv/LICENSE;md5=ad93ca1fffe931537fcf64f6fcce084d \ " # Strip ${prefix} from ${docdir}, set result into docdir_stripped @@ -38,11 +37,13 @@ EXTRA_OECMAKE=" \ -DCMAKE_DOC_DIR=${docdir_stripped}/cmake-${CMAKE_MAJOR_VERSION} \ -DCMAKE_USE_SYSTEM_LIBRARIES=1 \ -DCMAKE_USE_SYSTEM_LIBRARY_JSONCPP=0 \ + -DCMAKE_USE_SYSTEM_LIBRARY_CPPDAP=0 \ -DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=0 \ -DCMAKE_USE_SYSTEM_LIBRARY_LIBRHASH=0 \ -DKWSYS_CHAR_IS_SIGNED=1 \ -DBUILD_CursesDialog=0 \ -DKWSYS_LFS_WORKS=1 \ + -DCMake_ENABLE_DEBUGGER=0 \ " do_install:append:class-nativesdk() { From afb2764e3b34078eb4d07d130bcea6808cc1bbbc Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 22 Jun 2025 16:19:29 +1000 Subject: [PATCH 22/41] update CI to use GitHub workflow on scarthgap, armv7/aarch64/x86_64 --- .devcontainer/Dockerfile | 10 --- .devcontainer/devcontainer.json | 20 ------ .github/workflows/build.yml | 117 ++++++++++++++++++++++++++------ .gitlab-ci.yml | 30 -------- 4 files changed, 96 insertions(+), 81 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .gitlab-ci.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index b97f157..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu/.devcontainer/base.Dockerfile - -# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04 -ARG VARIANT="ubuntu-20.04" -FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} - -# Install BitBake dependencies -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev xterm python3-subunit mesa-common-dev zstd liblz4-tool file - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index aa27be3..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,20 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu -{ - "name": "Ubuntu", - "build": { - "dockerfile": "Dockerfile", - // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04 - // Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon. - "args": { "VARIANT": "ubuntu-20.04" } - }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "uname -a", - - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bfead9f..1b8f781 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,100 @@ -name: Build +name: build -on: [push] +on: + push: + pull_request: + workflow_dispatch: jobs: + yocto-aarch64: + runs-on: ubuntu-24.04 + container: + steps: + - name: Packages + run: | + sudo apt-get update + sudo apt install -y build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd + echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns + - name: Checkout Poky + uses: actions/checkout@v4 + with: + repository: yoctoproject/poky + path: poky + ref: scarthgap + fetch_depth: 0 + - name: Checkout Swift layer + uses: actions/checkout@v4 + with: + path: poky/meta-swift + fetch_depth: 0 + - name: Build + run: | + cd $GITHUB_WORKSPACE/poky + source oe-init-build-env + bitbake-layers add-layer ../meta-swift + rm -f conf/local.conf + echo 'MACHINE = "qemuarm64"' > conf/local.conf + echo 'INHERIT += "rm_work"' >> conf/local.conf + bitbake swift-hello-world - build: - name: Build - runs-on: ubuntu-latest - container: colemancda/meta-swift - strategy: - matrix: - machine: [beaglebone-yocto, qemuarm64] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Build - run: | - export SRC_ROOT=$GITHUB_WORKSPACE - export POKY_DIR=/tmp/poky - export MACHINE=${{ matrix.machine }} - cd /tmp/ - git clone --branch dunfell-23.0.20-cmake-3.22.3 https://github.com/MillerTechnologyPeru/poky.git - cd $SRC_ROOT - ./build.sh + yocto-armv7: + runs-on: ubuntu-24.04 + container: + steps: + - name: Packages + run: | + sudo apt-get update + sudo apt install -y build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd + echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns + - name: Checkout Poky + uses: actions/checkout@v4 + with: + repository: yoctoproject/poky + path: poky + ref: scarthgap + fetch_depth: 0 + - name: Checkout Swift layer + uses: actions/checkout@v4 + with: + path: poky/meta-swift + fetch_depth: 0 + - name: Build + run: | + cd $GITHUB_WORKSPACE/poky + source oe-init-build-env + bitbake-layers add-layer ../meta-swift + rm -f conf/local.conf + echo 'MACHINE = "qemuarm"' > conf/local.conf + echo 'INHERIT += "rm_work"' >> conf/local.conf + bitbake swift-hello-world + + yocto-x86_64: + runs-on: ubuntu-24.04 + container: + steps: + - name: Packages + run: | + sudo apt-get update + sudo apt install -y build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd + echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns + - name: Checkout Poky + uses: actions/checkout@v4 + with: + repository: yoctoproject/poky + path: poky + ref: scarthgap + fetch_depth: 0 + - name: Checkout Swift layer + uses: actions/checkout@v4 + with: + path: poky/meta-swift + fetch_depth: 0 + - name: Build + run: | + cd $GITHUB_WORKSPACE/poky + source oe-init-build-env + bitbake-layers add-layer ../meta-swift + rm -f conf/local.conf + echo 'MACHINE = "qemux86-64"' > conf/local.conf + echo 'INHERIT += "rm_work"' >> conf/local.conf + bitbake swift-hello-world diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index e7ba095..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,30 +0,0 @@ -stages: - - build - -build-armv7: - image: colemancda/meta-swift - stage: build - script: - - export SRC_ROOT=$(pwd) - - export MACHINE=beaglebone-yocto - - export POKY_DIR=/tmp/poky - - cd /tmp/ - - git clone --branch dunfell-23.0.20-cmake-3.22.3 https://github.com/MillerTechnologyPeru/poky.git - - cd $SRC_ROOT - - ./build.sh - tags: - - bastion-c5d.9xl - -build-arm64: - image: colemancda/meta-swift - stage: build - script: - - export SRC_ROOT=$(pwd) - - export MACHINE=qemuarm64 - - export POKY_DIR=/tmp/poky - - cd /tmp/ - - git clone --branch dunfell-23.0.20-cmake-3.22.3 https://github.com/MillerTechnologyPeru/poky.git - - cd $SRC_ROOT - - ./build.sh - tags: - - bastion-c5d.9xl From fc7d0c12bd5f2346f23c69288b0072df4d701445 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Tue, 24 Jun 2025 09:29:37 -0400 Subject: [PATCH 23/41] add Float16Support patch for armv7 --- recipes-devtools/swift/swift-stdlib.bb | 1 + ...-add-arm-to-float16support-for-armv7.patch | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 recipes-devtools/swift/swift-stdlib/0001-add-arm-to-float16support-for-armv7.patch diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index e01281e..99f1460 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -17,6 +17,7 @@ SRC_URI = "\ git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;name=libdispatch;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=libdispatch; \ git://github.com/swiftlang/swift-experimental-string-processing.git;protocol=https;name=stringproc;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-experimental-string-processing; \ git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax; \ + file://0001-add-arm-to-float16support-for-armv7.patch;striplevel=1; \ " S = "${WORKDIR}/swift" diff --git a/recipes-devtools/swift/swift-stdlib/0001-add-arm-to-float16support-for-armv7.patch b/recipes-devtools/swift/swift-stdlib/0001-add-arm-to-float16support-for-armv7.patch new file mode 100644 index 0000000..5d0c6ae --- /dev/null +++ b/recipes-devtools/swift/swift-stdlib/0001-add-arm-to-float16support-for-armv7.patch @@ -0,0 +1,24 @@ +From 59b301cf43388999cc230814043a9720710533e5 Mon Sep 17 00:00:00 2001 +From: "Jesse L. Zamora" +Date: Fri, 28 Feb 2025 15:27:33 -0500 +Subject: [PATCH] Add __arm__ to Float16Support for missing symbol + +--- + stdlib/public/runtime/Float16Support.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp +index fa259559e45..dfa9c9876de 100644 +--- a/stdlib/public/runtime/Float16Support.cpp ++++ b/stdlib/public/runtime/Float16Support.cpp +@@ -31,7 +31,7 @@ + // Android NDK Date: Wed, 25 Jun 2025 09:13:05 +1000 Subject: [PATCH 24/41] use Amazon Linux 2, rather than Ubuntu 24.04, as native Swift toolchain From the Apple Swift SDK generator: Amazon Linux 2 is chosen for its best compatibility with all Swift-supported Linux hosts Note, however, that we will eventually be moot when we build Swift from source (although perhaps we will use a binary distribution of Swift 5.9 to bootstrap the compiler). --- recipes-devtools/swift/swift-native.bb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes-devtools/swift/swift-native.bb b/recipes-devtools/swift/swift-native.bb index c9e73a9..604045b 100644 --- a/recipes-devtools/swift/swift-native.bb +++ b/recipes-devtools/swift/swift-native.bb @@ -16,8 +16,8 @@ def swift_native_arch_suffix(d): def swift_native_arch_checksum(d): sha256 = { - "x86_64": "d749d5fe2d6709ee988e96b16f02bca7b53304d09925e31063fd5ec56019de9f", - "aarch64": "0be937ec11860cad109ab422541643f7c6b1156daa91c9e2c70d8f03ce245cb6" + "x86_64": "3f4b7e2c9219a52fcecb7cb90153f9aacd3da85aa53e75e38dd406c0e9122551", + "aarch64": "9441091be33ca5d909337b8795f98e8234a52d79c197c6c015bca4b8994fbc87" } host_arch = d.getVar('HOST_ARCH') @@ -25,8 +25,10 @@ def swift_native_arch_checksum(d): SWIFT_ARCH_SUFFIX = "${@swift_native_arch_suffix(d)}" -SRC_DIR = "swift-${SWIFT_VERSION}-RELEASE-ubuntu24.04${SWIFT_ARCH_SUFFIX}" -SRC_URI = "https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2404${SWIFT_ARCH_SUFFIX}/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu24.04${SWIFT_ARCH_SUFFIX}.tar.gz" +SWIFT_LINUX_DISTRO = "amazonlinux2" + +SRC_DIR = "swift-${SWIFT_VERSION}-RELEASE-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}" +SRC_URI = "https://download.swift.org/swift-${SWIFT_VERSION}-release/${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}.tar.gz" SRC_URI[sha256sum] = "${@swift_native_arch_checksum(d)}" DEPENDS = "curl" From a8750600d28c55956d9ac050b817fe7e092c433f Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Wed, 25 Jun 2025 09:28:38 +1000 Subject: [PATCH 25/41] use C11 threading package on armv7 for some reason (yet to be determined), pthreads does not work with Swift concurrency on armv7 --- recipes-devtools/swift/swift-stdlib.bb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index 99f1460..9098e99 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -161,6 +161,11 @@ set(LibRT_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/librt.a) set(ZLIB_LIBRARY ${STAGING_DIR_TARGET}/usr/lib/libz.so) EOF + # pthreads does not work with armv7, so use c11 threading package in lieu + if [ "${SWIFT_TARGET_ARCH}" = "armv7" ]; then + echo "set(SWIFT_THREADING_PACKAGE c11)" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} + fi + cmake -S ${SWIFT_SRCDIR} -B ${SWIFT_BUILDDIR} -G Ninja \ -DSDKROOT=${STAGING_DIR_TARGET} \ -DCMAKE_SYSROOT=${STAGING_DIR_TARGET} \ From 8acabed4182699c835413bd1c68a24a98af84028 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Thu, 26 Jun 2025 21:29:27 +1000 Subject: [PATCH 26/41] don't assume all non-armv7 targets are aarch64 This is necessary for non-ARM architectures to build, although there are further changes needed for x86_64 to work. --- classes/swift-cmake-base.bbclass | 6 +++--- classes/swift.bbclass | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 848ea5a..14e089b 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -5,9 +5,9 @@ TOOLCHAIN = "gcc" DEPENDS:append = " swift-native libgcc gcc glibc " -SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aarch64', d)}" -SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" -TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', 'aarch64', d)}" +SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" +SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" +TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', '${TARGET_ARCH}', d)}" # Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key # RECIPE_MAINTAINER:pn-gcc-source- diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 95c2b50..e6b9738 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -20,8 +20,8 @@ BUILD_DIR = "${B}/${BUILD_MODE}" # Additional parameters to pass to SPM EXTRA_OESWIFT ?= "" -SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" -SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aarch64', d)}" +SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" +SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" do_fix_gcc_install_dir() { # symbolic links do not work, will not be found by Swift clang driver From b732321954dc9f19162fe186317bb45a769a43af Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Thu, 26 Jun 2025 22:18:22 +1000 Subject: [PATCH 27/41] add clang checks to sysdeps/x86/bits/floatn.h This is necessary to import float128 routines into Swift with glibc 2.39 or higher, when using clang instead of gcc. --- ...x86-Define-__HAVE_FLOAT128-for-Clang.patch | 78 +++++++++++++++++++ recipes-core/glibc/glibc_%.bbappend | 6 ++ 2 files changed, 84 insertions(+) create mode 100644 recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch create mode 100644 recipes-core/glibc/glibc_%.bbappend diff --git a/recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch b/recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch new file mode 100644 index 0000000..aae1ca8 --- /dev/null +++ b/recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch @@ -0,0 +1,78 @@ +From: Khem Raj +Date: Thu, 26 Dec 2024 18:59:26 -0800 + +Upstream-Status: Pending +Signed-off-by: Luke Howard + +diff --git a/sysdeps/x86/bits/floatn.h b/sysdeps/x86/bits/floatn.h +--- b/sysdeps/x86/bits/floatn.h ++++ a/sysdeps/x86/bits/floatn.h +@@ -28,7 +28,8 @@ + support, for x86_64 and x86. */ + #if (defined __x86_64__ \ + ? __GNUC_PREREQ (4, 3) \ ++ : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \ ++ || __glibc_clang_prereq (3, 4) +- : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) + # define __HAVE_FLOAT128 1 + #else + # define __HAVE_FLOAT128 0 +@@ -58,7 +59,9 @@ + /* Defined to concatenate the literal suffix to be used with _Float128 + types, if __HAVE_FLOAT128 is 1. */ + # if __HAVE_FLOAT128 ++# if !__GNUC_PREREQ (7, 0) \ ++ || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ ++ || defined __clang__ +-# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) + /* The literal suffix f128 exists only since GCC 7.0. */ + # define __f128(x) x##q + # else +@@ -68,7 +71,9 @@ + + /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ + # if __HAVE_FLOAT128 ++# if !__GNUC_PREREQ (7, 0) \ ++ || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ ++ || defined __clang__ +-# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) + /* Add a typedef for older GCC compilers which don't natively support + _Complex _Float128. */ + typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); +@@ -82,12 +87,14 @@ + # if __HAVE_FLOAT128 + + /* The type _Float128 exists only since GCC 7.0. */ ++# if !__GNUC_PREREQ (7, 0) \ ++ || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ ++ || __glibc_clang_prereq (3, 4) +-# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) + typedef __float128 _Float128; + # endif + ++/* __builtin_huge_valf128 doesn't exist before GCC 7.0 nor Clang 7.0. */ ++# if !__GNUC_PREREQ (7, 0) && !__glibc_clang_prereq (7, 0) +-/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */ +-# if !__GNUC_PREREQ (7, 0) + # define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ()) + # endif + +@@ -96,7 +103,7 @@ + Converting a narrower sNaN to _Float128 produces a quiet NaN, so + attempts to use _Float128 sNaNs will not work properly with older + compilers. */ ++# if !__GNUC_PREREQ (7, 0) && !defined __clang__ +-# if !__GNUC_PREREQ (7, 0) + # define __builtin_copysignf128 __builtin_copysignq + # define __builtin_fabsf128 __builtin_fabsq + # define __builtin_inff128() ((_Float128) __builtin_inf ()) +@@ -107,7 +114,8 @@ + /* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*, + e.g.: __builtin_signbitf128, before GCC 6. However, there has never + been a __builtin_signbitf128 in GCC and the type-generic builtin is ++ only available since GCC 6. signbit is expanded to __builtin_signbit ++ after Clang 3.3. */ +- only available since GCC 6. */ + # if !__GNUC_PREREQ (6, 0) + # define __builtin_signbitf128 __signbitf128 + # endif diff --git a/recipes-core/glibc/glibc_%.bbappend b/recipes-core/glibc/glibc_%.bbappend new file mode 100644 index 0000000..aeb47e2 --- /dev/null +++ b/recipes-core/glibc/glibc_%.bbappend @@ -0,0 +1,6 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI += "\ + file://0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch \ + " + From f25ce41478bf86444830ccaeb09d30c6c1b87c51 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Fri, 27 Jun 2025 12:01:59 +1000 Subject: [PATCH 28/41] remove local copy of CMake 3.28.3 recipes removing this in anticipation of this branch being merged into an upstream branch named 'scarthgap'. This commit may be reverted if this layer needs to be backported to earlier Yocto versions that have versions of CMake with which Swift cannot build. --- recipes-devtools/cmake/cmake-native_3.28.3.bb | 67 ------------------ recipes-devtools/cmake/cmake.inc | 27 -------- ...mpilerABI-Strip-pipe-from-compile-fl.patch | 52 -------------- ...1-CMakeLists.txt-disable-USE_NGHTTP2.patch | 35 ---------- ...xt2fs-ext2_fs.h-by-cmake-s-internal-.patch | 39 ----------- .../cmake/cmake/OEToolchainConfig.cmake | 23 ------- .../cmake/SDKToolchainConfig.cmake.template | 31 --------- recipes-devtools/cmake/cmake/cmake-setup.py | 33 --------- .../cmake/cmake/environment.d-cmake.sh | 2 - recipes-devtools/cmake/cmake_3.28.3.bb | 68 ------------------- 10 files changed, 377 deletions(-) delete mode 100644 recipes-devtools/cmake/cmake-native_3.28.3.bb delete mode 100644 recipes-devtools/cmake/cmake.inc delete mode 100644 recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch delete mode 100644 recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch delete mode 100644 recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch delete mode 100644 recipes-devtools/cmake/cmake/OEToolchainConfig.cmake delete mode 100644 recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template delete mode 100755 recipes-devtools/cmake/cmake/cmake-setup.py delete mode 100644 recipes-devtools/cmake/cmake/environment.d-cmake.sh delete mode 100644 recipes-devtools/cmake/cmake_3.28.3.bb diff --git a/recipes-devtools/cmake/cmake-native_3.28.3.bb b/recipes-devtools/cmake/cmake-native_3.28.3.bb deleted file mode 100644 index 546d117..0000000 --- a/recipes-devtools/cmake/cmake-native_3.28.3.bb +++ /dev/null @@ -1,67 +0,0 @@ -require cmake.inc -inherit native - -DEPENDS += "bzip2-replacement-native xz-native zlib-native ncurses-native zstd-native openssl-native" - -SRC_URI += "file://OEToolchainConfig.cmake \ - file://environment.d-cmake.sh \ - file://0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch \ - file://0001-CMakeLists.txt-disable-USE_NGHTTP2.patch \ - " - -LICENSE:append = " & BSD-1-Clause & MIT & BSD-2-Clause & curl" -LIC_FILES_CHKSUM:append = " \ - file://Utilities/cmjsoncpp/LICENSE;md5=5d73c165a0f9e86a1342f32d19ec5926 \ - file://Utilities/cmlibarchive/COPYING;md5=d499814247adaee08d88080841cb5665 \ - file://Utilities/cmexpat/COPYING;md5=9e2ce3b3c4c0f2670883a23bbd7c37a9 \ - file://Utilities/cmlibrhash/COPYING;md5=a8c2a557a5c53b1c12cddbee98c099af \ - file://Utilities/cmlibuv/LICENSE;md5=ad93ca1fffe931537fcf64f6fcce084d \ - file://Utilities/cmcurl/COPYING;md5=db8448a1e43eb2125f7740fc397db1f6 \ -" - -B = "${WORKDIR}/build" -do_configure[cleandirs] = "${B}" - -CMAKE_EXTRACONF = "\ - -DCMAKE_LIBRARY_PATH=${STAGING_LIBDIR_NATIVE} \ - -DBUILD_CursesDialog=1 \ - -DCMAKE_USE_SYSTEM_LIBRARIES=1 \ - -DCMAKE_USE_SYSTEM_LIBRARY_JSONCPP=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_CPPDAP=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_LIBRHASH=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_EXPAT=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_CURL=0 \ - -DENABLE_ACL=0 -DHAVE_ACL_LIBACL_H=0 \ - -DHAVE_SYS_ACL_H=0 \ -" - -do_configure () { - ${S}/bootstrap --verbose --prefix=${prefix} \ - ${@oe.utils.parallel_make_argument(d, '--parallel=%d')} \ - ${@bb.utils.contains('CCACHE', 'ccache ', '--enable-ccache', '', d)} \ - -- ${CMAKE_EXTRACONF} -} - -do_compile() { - oe_runmake -} - -do_install() { - oe_runmake 'DESTDIR=${D}' install - - # The following codes are here because eSDK needs to provide compatibilty - # for SDK. That is, eSDK could also be used like traditional SDK. - mkdir -p ${D}${datadir}/cmake - install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/ - mkdir -p ${D}${base_prefix}/environment-setup.d - install -m 644 ${WORKDIR}/environment.d-cmake.sh ${D}${base_prefix}/environment-setup.d/cmake.sh - - # Help docs create tons of files in the native sysroot and aren't needed there - rm -rf ${D}${datadir}/cmake-*/Help -} - -do_compile[progress] = "percent" - -SYSROOT_DIRS_NATIVE += "${datadir}/cmake ${base_prefix}/environment-setup.d" diff --git a/recipes-devtools/cmake/cmake.inc b/recipes-devtools/cmake/cmake.inc deleted file mode 100644 index a52506a..0000000 --- a/recipes-devtools/cmake/cmake.inc +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2005, Koninklijke Philips Electronics NV. All Rights Reserved -# Released under the MIT license (see packages/COPYING) - -SUMMARY = "Cross-platform, open-source make system" -DESCRIPTION = "CMake is used to control the software compilation process \ -using simple platform and compiler independent configuration files. CMake \ -generates native makefiles and workspaces that can be used in the compiler \ -environment of your choice." -HOMEPAGE = "http://www.cmake.org/" -BUGTRACKER = "http://public.kitware.com/Bug/my_view_page.php" -SECTION = "console/utils" -LICENSE = "BSD-3-Clause" -LIC_FILES_CHKSUM = "file://Copyright.txt;md5=9d3d12c5f3b4c1f83650adcc65b59c06 \ - file://Source/cmake.h;beginline=1;endline=2;md5=a5f70e1fef8614734eae0d62b4f5891b \ - " - -CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" - -SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \ - file://0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch \ - " - -SRC_URI[sha256sum] = "72b7570e5c8593de6ac4ab433b73eab18c5fb328880460c86ce32608141ad5c1" - -UPSTREAM_CHECK_REGEX = "cmake-(?P\d+(\.\d+)+)\.tar" - -CVE_STATUS[CVE-2016-10642] = "cpe-incorrect: This is specific to the npm package that installs cmake, so isn't relevant to OpenEmbedded" diff --git a/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch b/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch deleted file mode 100644 index 7ffcc95..0000000 --- a/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch +++ /dev/null @@ -1,52 +0,0 @@ -From bd94bbdc35a9da4c73d538e0cc55bc95944f620d Mon Sep 17 00:00:00 2001 -From: Philip Lorenz -Date: Mon, 3 Jun 2024 13:19:24 +0200 -Subject: [PATCH] CMakeDetermineCompilerABI: Strip -pipe from compile flags - -When `-pipe` is enabled, GCC passes data between its different -executables using pipes instead of temporary files. This leads to issues -when cmake attempts to infer compiler internals via the `-v` parameter -as each executable will print to `stderr` in parallel. - -For example we have observed the following outputs in our builds which -sporadically lead to build failures as system include directories were -not detected reliably: - -Parsed CXX implicit include dir info from above output: rv=done - found start of include info - found start of implicit include info - add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include] - add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include-fixed] - add: [.../usr/include/c++/11.4.0] - add: [.../usr/include/c++/11.4.0/x86_64-poky-linux] - add: [.../usr/include/c++/11.4.0/backward] - add: [.../usr/lib/x86_64-poky-linux/11.4.0/include] - add: [...GNU assembler version 2.38 (x86_64-poky-linux) using BFD version (GNU Binutils) 2.38.20220708] - add: [/usr/include] - end of search list found - -Fix this issue by stripping the `-pipe` parameter from the compilation -flag when determining the toolchain configuration. - -Upstream-Status: Backport [3.32.0, 71be059f3f32b6791427893a48ba4815a19e2e78] -Signed-off-by: Philip Lorenz ---- - Modules/CMakeDetermineCompilerABI.cmake | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake -index efc18f93c2..f2e40479b1 100644 ---- a/Modules/CMakeDetermineCompilerABI.cmake -+++ b/Modules/CMakeDetermineCompilerABI.cmake -@@ -43,6 +43,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) - - # Avoid failing ABI detection on warnings. - string(REGEX REPLACE "(^| )-Werror([= ][^-][^ ]*)?( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") -+ # Avoid passing of "-pipe" when determining the compiler internals. With -+ # "-pipe" GCC will use pipes to pass data between the involved -+ # executables. This may lead to issues when their stderr output (which -+ # contains the relevant compiler internals) becomes interweaved. -+ string(REGEX REPLACE "(^| )-pipe( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") - - # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables - # and set them to "C" that way GCC's "search starts here" text is in diff --git a/recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch b/recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch deleted file mode 100644 index b2933d8..0000000 --- a/recipes-devtools/cmake/cmake/0001-CMakeLists.txt-disable-USE_NGHTTP2.patch +++ /dev/null @@ -1,35 +0,0 @@ -From d33d8a5e9f3b25a80d47b72b1a8a6624a85563c1 Mon Sep 17 00:00:00 2001 -From: Changqing Li -Date: Wed, 28 Dec 2022 17:51:27 +0800 -Subject: [PATCH] CMakeLists.txt: disable USE_NGHTTP2 - -nghttp2 depends on cmake-native to build, to break circular -dependency, disable nghttp2. - -Upstream-Status: Inappropriate [oe specific] - -Signed-off-by: Changqing Li - -Adjust the patch to apply on top of v3.28.3. - -Signed-off-by: Trevor Gamblin ---- - Utilities/cmcurl/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt -index 9387247366..d3de01f4e8 100644 ---- a/Utilities/cmcurl/CMakeLists.txt -+++ b/Utilities/cmcurl/CMakeLists.txt -@@ -88,7 +88,7 @@ set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only") - set(PICKY_COMPILER OFF CACHE INTERNAL "Enable picky compiler options") - set(SHARE_LIB_OBJECT OFF) - set(USE_LIBIDN2 ON) --set(USE_NGHTTP2 ON) -+set(USE_NGHTTP2 OFF) - set(USE_NGTCP2 OFF) - set(USE_QUICHE OFF) - set(USE_WIN32_IDN OFF) --- -2.43.0 - diff --git a/recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch b/recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch deleted file mode 100644 index d6f7308..0000000 --- a/recipes-devtools/cmake/cmake/0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch +++ /dev/null @@ -1,39 +0,0 @@ -From fd9a04c1434e12f21c043385e306e0b52d38d749 Mon Sep 17 00:00:00 2001 -From: Otavio Salvador -Date: Thu, 5 Jul 2018 10:28:04 -0300 -Subject: [PATCH] Disable use of ext2fs/ext2_fs.h by cmake's internal - - libarchive copy -Organization: O.S. Systems Software LTDA. - -We don't want to add a dependency on e2fsprogs-native for cmake-native, -and we don't use CPack so just disable this functionality. - -Upstream-Status: Inappropriate [config] - -Signed-off-by: Paul Eggleton -Signed-off-by: Otavio Salvador - ---- - Utilities/cmlibarchive/CMakeLists.txt | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt -index bfcaf30..2960683 100644 ---- a/Utilities/cmlibarchive/CMakeLists.txt -+++ b/Utilities/cmlibarchive/CMakeLists.txt -@@ -682,12 +682,8 @@ LA_CHECK_INCLUDE_FILE("copyfile.h" HAVE_COPYFILE_H) - LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H) - LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H) - LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H) --LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H) -- --CHECK_C_SOURCE_COMPILES("#include --#include --int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS) -- -+SET(HAVE_EXT2FS_EXT2_FS_H 0) -+SET(HAVE_WORKING_EXT2_IOC_GETFLAGS 0) - LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H) - LA_CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H) - LA_CHECK_INCLUDE_FILE("io.h" HAVE_IO_H) diff --git a/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake b/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake deleted file mode 100644 index 6434b27..0000000 --- a/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake +++ /dev/null @@ -1,23 +0,0 @@ -set( CMAKE_SYSTEM_NAME Linux ) -set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) -set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE ) -set( CMAKE_SYSROOT $ENV{OECORE_TARGET_SYSROOT} ) - -set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} ) -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY ) - -set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "$ENV{OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX}") - -set( CMAKE_SYSTEM_PROCESSOR $ENV{OECORE_TARGET_ARCH} ) - -# Include the toolchain configuration subscripts -file( GLOB toolchain_config_files "${CMAKE_CURRENT_LIST_FILE}.d/*.cmake" ) -foreach(config ${toolchain_config_files}) - include(${config}) -endforeach() - -unset(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES) -unset(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES) diff --git a/recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template b/recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template deleted file mode 100644 index c69569a..0000000 --- a/recipes-devtools/cmake/cmake/SDKToolchainConfig.cmake.template +++ /dev/null @@ -1,31 +0,0 @@ -set(SDK_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..") -set(HOST_SYSROOT "${SDK_INSTALL_DIR}/sysroots/@OECORE_SDK_SYS") -set(TARGET_SYSROOT "${SDK_INSTALL_DIR}/sysroots/@OECORE_TARGET_SYS") -set(HOST_BIN "${HOST_SYSROOT}/usr/bin") -set(TOOLCHAIN_NAME "@OECORE_TARGET_ALIAS") -set(GCC_DIR "${HOST_BIN}/${TOOLCHAIN_NAME}") - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR "@OECORE_TARGET_ARCH") - -set(CMAKE_C_COMPILER "${GCC_DIR}/${TOOLCHAIN_NAME}-gcc") -set(CMAKE_CXX_COMPILER "${GCC_DIR}/${TOOLCHAIN_NAME}-g++") - -set(ARCH_FLAGS "@OECORE_TUNE_CCARGS") -set(CMAKE_C_FLAGS "${ARCH_FLAGS}" CACHE STRING "" FORCE ) -set(CMAKE_CXX_FLAGS "${ARCH_FLAGS}" CACHE STRING "" FORCE ) -set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE ) -set(CMAKE_LDFLAGS_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE ) - -set(CMAKE_SYSROOT "${TARGET_SYSROOT}") - -set(CMAKE_FIND_ROOT_PATH "${TARGET_SYSROOT}" ) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY ) - -set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "") - -set(CMAKE_PROGRAM_PATH "${HOST_SYSROOT}/usr/bin" CACHE STRING "" FORCE) diff --git a/recipes-devtools/cmake/cmake/cmake-setup.py b/recipes-devtools/cmake/cmake/cmake-setup.py deleted file mode 100755 index af587a4..0000000 --- a/recipes-devtools/cmake/cmake/cmake-setup.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 - -import os -import string -import sys - -class Template(string.Template): - delimiter = "@" - -class Environ(): - def __getitem__(self, name): - if name == "OECORE_SDK_SYS": - return os.path.basename(os.environ["OECORE_NATIVE_SYSROOT"]) - elif name == "OECORE_TARGET_SYS": - return os.path.basename(os.environ["OECORE_TARGET_SYSROOT"]) - elif name == "OECORE_TARGET_ALIAS": - return os.path.basename(os.environ["TARGET_PREFIX"].strip("-")) - else: - return os.environ[name] - -try: - sysroot = os.environ['OECORE_NATIVE_SYSROOT'] -except KeyError: - print("Not in environment setup, bailing") - sys.exit(1) - -template_file = os.path.join(sysroot, 'usr/share/cmake/SDKToolchainConfig.cmake.template') -cross_file = os.path.join(sysroot, 'usr/share/cmake/%s-toolchain.cmake' % (os.path.basename(os.environ["OECORE_TARGET_SYSROOT"]))) -with open(template_file) as in_file: - template = in_file.read() - output = Template(template).substitute(Environ()) - with open(cross_file, "w") as out_file: - out_file.write(output) diff --git a/recipes-devtools/cmake/cmake/environment.d-cmake.sh b/recipes-devtools/cmake/cmake/environment.d-cmake.sh deleted file mode 100644 index c94b6bb..0000000 --- a/recipes-devtools/cmake/cmake/environment.d-cmake.sh +++ /dev/null @@ -1,2 +0,0 @@ -export CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" -export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`" diff --git a/recipes-devtools/cmake/cmake_3.28.3.bb b/recipes-devtools/cmake/cmake_3.28.3.bb deleted file mode 100644 index 6a9a326..0000000 --- a/recipes-devtools/cmake/cmake_3.28.3.bb +++ /dev/null @@ -1,68 +0,0 @@ -require cmake.inc - -inherit cmake bash-completion - -DEPENDS += "curl expat zlib libarchive xz ncurses bzip2" - -SRC_URI:append:class-nativesdk = " \ - file://OEToolchainConfig.cmake \ - file://SDKToolchainConfig.cmake.template \ - file://cmake-setup.py \ - file://environment.d-cmake.sh \ -" - -LICENSE:append = " & BSD-1-Clause & MIT" -LIC_FILES_CHKSUM:append = " \ - file://Utilities/cmjsoncpp/LICENSE;md5=5d73c165a0f9e86a1342f32d19ec5926 \ - file://Utilities/cmlibrhash/COPYING;md5=a8c2a557a5c53b1c12cddbee98c099af \ - file://Utilities/cmlibuv/LICENSE;md5=ad93ca1fffe931537fcf64f6fcce084d \ -" - -# Strip ${prefix} from ${docdir}, set result into docdir_stripped -python () { - prefix=d.getVar("prefix") - docdir=d.getVar("docdir") - - if not docdir.startswith(prefix): - bb.fatal('docdir must contain prefix as its prefix') - - docdir_stripped = docdir[len(prefix):] - if len(docdir_stripped) > 0 and docdir_stripped[0] == '/': - docdir_stripped = docdir_stripped[1:] - - d.setVar("docdir_stripped", docdir_stripped) -} - -EXTRA_OECMAKE=" \ - -DCMAKE_DOC_DIR=${docdir_stripped}/cmake-${CMAKE_MAJOR_VERSION} \ - -DCMAKE_USE_SYSTEM_LIBRARIES=1 \ - -DCMAKE_USE_SYSTEM_LIBRARY_JSONCPP=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_CPPDAP=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=0 \ - -DCMAKE_USE_SYSTEM_LIBRARY_LIBRHASH=0 \ - -DKWSYS_CHAR_IS_SIGNED=1 \ - -DBUILD_CursesDialog=0 \ - -DKWSYS_LFS_WORKS=1 \ - -DCMake_ENABLE_DEBUGGER=0 \ -" - -do_install:append:class-nativesdk() { - mkdir -p ${D}${datadir}/cmake - install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/ - - mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d - install -m 644 ${WORKDIR}/environment.d-cmake.sh ${D}${SDKPATHNATIVE}/environment-setup.d/cmake.sh - - # install cmake-setup.py to create arch-specific toolchain cmake file from template - install -m 0644 ${WORKDIR}/SDKToolchainConfig.cmake.template ${D}${datadir}/cmake/ - install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d - install -m 0755 ${WORKDIR}/cmake-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/ -} - -FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}" - -FILES:${PN} += "${datadir}/cmake-${CMAKE_MAJOR_VERSION} ${datadir}/cmake ${datadir}/aclocal ${datadir}/emacs ${datadir}/vim" -FILES:${PN}-doc += "${docdir}/cmake-${CMAKE_MAJOR_VERSION}" -FILES:${PN}-dev = "" - -BBCLASSEXTEND = "nativesdk" From 2bdd14f4e42922353ccf6c44858938c1372a673f Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 15:36:17 +1000 Subject: [PATCH 29/41] fix build with 64-bit time_t/off_t on 32-bit platforms It is possible to build with 64-bit timestamps and file offsets on 32-bit platforms such as armv7 (e.g. for avoiding Y2038), and indeed this is the default for Yocto. This is (presently) broken in upstream Swift, so workaround until we can get PRs merged upstream. --- .../swift/swift-foundation-essentials.bb | 2 + ...t-fsblkcnt_t-on-32-bit-glibc-platfor.patch | 33 ++++++++++++ ...th-64-bit-time_t-on-32-bit-platforms.patch | 34 ++++++++++++ recipes-devtools/swift/swift-foundation.bb | 1 + ...th-64-bit-time_t-on-32-bit-platforms.patch | 34 ++++++++++++ recipes-devtools/swift/swift-stdlib.bb | 1 + ...th-64-bit-time_t-on-32-bit-platforms.patch | 54 +++++++++++++++++++ 7 files changed, 159 insertions(+) create mode 100644 recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch create mode 100644 recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch create mode 100644 recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch create mode 100644 recipes-devtools/swift/swift-stdlib/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch diff --git a/recipes-devtools/swift/swift-foundation-essentials.bb b/recipes-devtools/swift/swift-foundation-essentials.bb index 98e9cda..b5765e6 100644 --- a/recipes-devtools/swift/swift-foundation-essentials.bb +++ b/recipes-devtools/swift/swift-foundation-essentials.bb @@ -13,6 +13,8 @@ SRC_URI = "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=f SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" SRC_URI += "git://github.com/apple/swift-collections.git;protocol=https;nobranch=1;name=collections;tag=1.1.4;destsuffix=swift-collections;" +SRC_URI += "file://0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch;striplevel=1;" +SRC_URI += "file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1;" S = "${WORKDIR}/git" diff --git a/recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch b/recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch new file mode 100644 index 0000000..efad4c6 --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch @@ -0,0 +1,33 @@ +From 3eb8a04f9597ed71ddd3eb54db77a9d5e37f032d Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 11:58:13 +1000 +Subject: [PATCH 1/2] build with 64-bit fsblkcnt_t on 32-bit glibc platforms + +It is possible to build with 64-bit file offsets on 32-bit platforms such as +armv7, and indeed this is the default for some build environments such as +Yocto. Use fsblkcnt_t, which is an alias to a type of the correct width, when +computing blockSize. +--- + .../FoundationEssentials/FileManager/FileManager+Files.swift | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +index 64f8e21..824c3ac 100644 +--- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift ++++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +@@ -727,8 +727,12 @@ extension _FileManagerImpl { + let blockSize = UInt64(result.f_bsize) + #else + let fsNumber = result.f_fsid ++ #if canImport(Glibc) ++ let blockSize = fsblkcnt_t(result.f_frsize) // support 64-bit block sizes on 32-bit platforms ++ #else + let blockSize = UInt(result.f_frsize) + #endif ++ #endif + var totalSizeBytes = result.f_blocks * blockSize + var availSizeBytes = result.f_bavail * blockSize + var totalFiles = result.f_files +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch b/recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch new file mode 100644 index 0000000..a955bea --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch @@ -0,0 +1,34 @@ +From ad2b4b35979caf1d66d77933dda66012f7108294 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 11:59:30 +1000 +Subject: [PATCH 2/2] build with 64-bit time_t on 32-bit platforms + +It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to +avoid the Y2038 issue. This is the default when building on Yocto for armv7, +for example. Unfortunately suseconds_t is not an alias to a type of the correct +width (unlike time_t), so for Glibc make it a private alias of time_t to fix +the build. +--- + .../FileManager/FileManager+Files.swift | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +index 824c3ac..c7ea78c 100644 +--- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift ++++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +@@ -951,6 +951,12 @@ extension _FileManagerImpl { + #endif + } + ++ #if canImport(Glibc) ++ // support for 64-bit timestamps on 32-bit platforms; unfortunately ++ // suseconds_t is not an alias of the appropriate type, but time_t is ++ typealias suseconds_t = time_t ++ #endif ++ + if let date = attributes[.modificationDate] as? Date { + let (isecs, fsecs) = modf(date.timeIntervalSince1970) + if let tv_sec = time_t(exactly: isecs), +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-foundation.bb b/recipes-devtools/swift/swift-foundation.bb index b0d1daf..813495d 100644 --- a/recipes-devtools/swift/swift-foundation.bb +++ b/recipes-devtools/swift/swift-foundation.bb @@ -14,6 +14,7 @@ SRC_URI += "git://github.com/swiftlang/swift-foundation.git;protocol=https;name= SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax;" SRC_URI += "file://0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch;striplevel=1;" +SRC_URI += "file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1;" S = "${WORKDIR}/git" diff --git a/recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch b/recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch new file mode 100644 index 0000000..a0484cb --- /dev/null +++ b/recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch @@ -0,0 +1,34 @@ +From 214f7205f8a4065c6b4b5ac3471167bd1edc475f Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 12:04:30 +1000 +Subject: [PATCH] build with 64-bit time_t on 32-bit platforms + +It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to +avoid the Y2038 issue. This is the default when building on Yocto for armv7, +for example. Unfortunately suseconds_t is not an alias to a type of the correct +width (unlike time_t), so for Glibc make it a private alias of time_t to fix +the build. +--- + Sources/Foundation/NSDate.swift | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/Sources/Foundation/NSDate.swift b/Sources/Foundation/NSDate.swift +index ac7bd1bc..77579282 100644 +--- a/Sources/Foundation/NSDate.swift ++++ b/Sources/Foundation/NSDate.swift +@@ -30,6 +30,12 @@ extension TimeInterval { + #else + extension timeval { + internal init(_timeIntervalSince1970: TimeInterval) { ++ #if canImport(Glibc) ++ // support for 64-bit timestamps on 32-bit platforms; unfortunately ++ // suseconds_t is not an alias of the appropriate type, but time_t is ++ typealias suseconds_t = time_t ++ #endif ++ + let (integral, fractional) = modf(_timeIntervalSince1970) + self.init(tv_sec: time_t(integral), tv_usec: suseconds_t(1.0e6 * fractional)) + } +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index 9098e99..9160b40 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -18,6 +18,7 @@ SRC_URI = "\ git://github.com/swiftlang/swift-experimental-string-processing.git;protocol=https;name=stringproc;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-experimental-string-processing; \ git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax; \ file://0001-add-arm-to-float16support-for-armv7.patch;striplevel=1; \ + file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1; \ " S = "${WORKDIR}/swift" diff --git a/recipes-devtools/swift/swift-stdlib/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch b/recipes-devtools/swift/swift-stdlib/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch new file mode 100644 index 0000000..b567477 --- /dev/null +++ b/recipes-devtools/swift/swift-stdlib/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch @@ -0,0 +1,54 @@ +From 06073712f137bd1db7f0b94f4526b00be81ec3fb Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 15:01:30 +1000 +Subject: [PATCH] build with 64-bit time_t on 32-bit platforms + +It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to +avoid the Y2038 issue. This is the default when building on Yocto for armv7, +for example. Unfortunately suseconds_t is not an alias to a type of the correct +width (unlike time_t). +--- + stdlib/public/Platform/Platform.swift | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift +index 0c2d63a0cff..4949fc66456 100644 +--- a/stdlib/public/Platform/Platform.swift ++++ b/stdlib/public/Platform/Platform.swift +@@ -439,7 +439,7 @@ extension timespec { + @available(SwiftStdlib 5.7, *) + public init(_ duration: Duration) { + let comps = duration.components +- self.init(tv_sec: Int(comps.seconds), ++ self.init(tv_sec: time_t(comps.seconds), + tv_nsec: Int(comps.attoseconds / 1_000_000_000)) + } + } +@@ -458,14 +458,18 @@ extension timeval { + public init(_ duration: Duration) { + let comps = duration.components + #if os(Linux) +- // Linux platforms define timeval as Int/Int +- self.init(tv_sec: Int(comps.seconds), +- tv_usec: Int(comps.attoseconds / 1_000_000_000_000)) ++ // Linux platforms define timeval as Int/Int, except on 32-bit platforms ++ // where _TIME_BITS=64 is defined. Abuse time_t as an alias for the correct ++ // suseconds_t type, as it is not an alias to the 64-bit type on 32-bit ++ // platforms. ++ typealias _Seconds = time_t ++ typealias _Microseconds = time_t + #else +- // Darwin platforms define timeval as Int/Int32 +- self.init(tv_sec: Int(comps.seconds), +- tv_usec: Int32(comps.attoseconds / 1_000_000_000_000)) ++ typealias _Seconds = Int ++ typealias _Microseconds = Int32 + #endif ++ self.init(tv_sec: _Seconds(comps.seconds), ++ tv_usec: _Microseconds(comps.attoseconds / 1_000_000_000_000)) + } + } + +-- +2.39.5 (Apple Git-154) + From 470ade302d2fdb4d32eb959e13b8b3432efacc64 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 10:54:37 +1000 Subject: [PATCH 30/41] ensure tune flags are passed to clang when building Swift recipes Yocto defines target-specific tune flags in the TARGET_CC_ARCH variable. Expand these and include them in destination.json so they are used when SwiftPM is compiling C. --- classes/swift-cmake-base.bbclass | 22 ++++++++++++++++++++-- classes/swift.bbclass | 24 ++++++++++++++++++++++++ recipes-devtools/swift/swift-stdlib.bb | 2 +- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 14e089b..e14c646 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -12,10 +12,27 @@ TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', '${T # Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key # RECIPE_MAINTAINER:pn-gcc-source- python () { + import shlex + gcc_src_maint_pkg = [x for x in d if x.startswith("RECIPE_MAINTAINER:pn-gcc-source-")][0] gcc_ver = gcc_src_maint_pkg.rpartition("-")[2] d.setVar("SWIFT_GCC_VERSION", gcc_ver) + + def expand_swiftc_cc_flags(flags): + flags = [['-Xcc', flag] for flag in flags] + return sum(flags, []) + + def concat_flags(flags): + return " ".join(flags) + + # ensure target-specific tune CC flags are propagated to clang and swiftc. + # Note we are not doing this at present for LD flags, as there are none in + # the architectures we support (and it would make the string expansion more + # complicated). + target_cc_arch = shlex.split(d.getVar("TARGET_CC_ARCH")) + + d.setVar("SWIFT_EXTRA_SWIFTC_CC_FLAGS", concat_flags(expand_swiftc_cc_flags(target_cc_arch))) } EXTRA_INCLUDE_FLAGS ?= "\ @@ -48,8 +65,8 @@ OECMAKE_C_COMPILER = "clang" OECMAKE_CXX_COMPILER = "clang++" # Point clang to where the C++ runtime is for our target arch -RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" -TARGET_LDFLAGS:append = " -w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" +RUNTIME_FLAGS = "${TARGET_CC_ARCH} -w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" +TARGET_LDFLAGS:append = " ${TARGET_LD_ARCH} -w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" OECMAKE_C_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" OECMAKE_CXX_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" @@ -70,6 +87,7 @@ SWIFT_FLAGS = "-target ${SWIFT_TARGET_NAME} -use-ld=lld \ -module-cache-path ${B}/${BUILD_MODE}/ModuleCache \ -Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib \ -Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} \ + ${SWIFT_EXTRA_SWIFTC_CC_FLAGS} \ -Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION}/include \ -Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION}/include-fixed \ -L${STAGING_DIR_TARGET} \ diff --git a/classes/swift.bbclass b/classes/swift.bbclass index e6b9738..9e8c4dc 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -90,6 +90,7 @@ python swift_do_configure() { import os import os.path import shutil + import shlex workdir = d.getVar("WORKDIR", True) recipe_sysroot = d.getVar("STAGING_DIR_TARGET", True) @@ -114,6 +115,23 @@ python swift_do_configure() { d.setVar('SWIFT_CXX_VERSION', cxx_version) + def expand_swiftc_cc_flags(flags): + flags = [['-Xcc', flag] for flag in flags] + return sum(flags, []) + + def concat_flags(flags): + flags = [f'"{flag}"' for flag in flags] + return ", ".join(flags) + + # ensure target-specific tune CC flags are propagated to clang and swiftc. + # Note we are not doing this at present for LD flags, as there are none in + # the architectures we support (and it would make the string expansion more + # complicated). + target_cc_arch = shlex.split(d.getVar("TARGET_CC_ARCH")) + + d.setVar("SWIFT_EXTRA_CC_FLAGS", concat_flags(target_cc_arch)) + d.setVar("SWIFT_EXTRA_SWIFTC_CC_FLAGS", concat_flags(expand_swiftc_cc_flags(target_cc_arch))) + swift_destination_template = """{ "version":1, "sdk":"${STAGING_DIR_TARGET}/", @@ -121,6 +139,7 @@ python swift_do_configure() { "target":"${SWIFT_TARGET_NAME}", "dynamic-library-extension":"so", "extra-cc-flags":[ + ${SWIFT_EXTRA_CC_FLAGS}, "-fPIC", "-I${STAGING_INCDIR}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}", @@ -166,9 +185,11 @@ python swift_do_configure() { "-resource-dir", "${STAGING_DIR_TARGET}/usr/lib/swift", "-module-cache-path", "${B}/${BUILD_MODE}/ModuleCache", + "-Xclang-linker", "-B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_CXX_VERSION}", "-Xclang-linker", "-B${STAGING_DIR_TARGET}/usr/lib", + ${SWIFT_EXTRA_SWIFTC_CC_FLAGS}, "-Xcc", "--gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_CXX_VERSION}", "-sdk", "${STAGING_DIR_TARGET}" @@ -182,6 +203,9 @@ python swift_do_configure() { d.delVar("SWIFT_CXX_VERSION") + d.delVar("SWIFT_EXTRA_CC_FLAGS") + d.delVar("SWIFT_EXTRA_SWIFTC_CC_FLAGS") + configJSON = open(workdir + "/destination.json", "w") configJSON.write(swift_destination) configJSON.close() diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index 9160b40..df49a4a 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -151,7 +151,7 @@ set(SWIFT_ENABLE_SYNCHRONIZATION ON) set(SWIFT_PATH_TO_STRING_PROCESSING_SOURCE ${WORKDIR}/swift-experimental-string-processing) set(SWIFT_SYNTAX_SOURCE_DIR ${WORKDIR}/swift-syntax) set(SWIFTSYNTAX_SOURCE_DIR ${WORKDIR}/swift-syntax) -set(SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS -Xcc --gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION}/${TARGET_SYS} -no-verify-emitted-module-interface) +set(SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS -Xcc --gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION}/${TARGET_SYS} -no-verify-emitted-module-interface ${SWIFT_EXTRA_SWIFTC_CC_FLAGS}) set(SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS "") set(ICU_I18N_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/libicui18n.so) From 390ff0185b1688fe64a0bc7d9ff711ca4b8dcd77 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 15:33:34 +1000 Subject: [PATCH 31/41] Don't override FORTIFY_SOURCE when building Foundation Overriding FORTIFY_SOURCE with lcl_maybe_fortify may cause clang module conflicts with consumers that do not override it identically. Not disabling FORTIFY_SOURCE should have minimal performance impact. [1] [1] https://zatoichi-engineer.github.io/2017/10/06/fortify-source.html --- recipes-devtools/swift/swift-foundation-essentials.bb | 2 -- recipes-devtools/swift/swift-foundation-icu.bb | 2 -- recipes-devtools/swift/swift-foundation.bb | 2 -- 3 files changed, 6 deletions(-) diff --git a/recipes-devtools/swift/swift-foundation-essentials.bb b/recipes-devtools/swift/swift-foundation-essentials.bb index b5765e6..4eba0af 100644 --- a/recipes-devtools/swift/swift-foundation-essentials.bb +++ b/recipes-devtools/swift/swift-foundation-essentials.bb @@ -33,8 +33,6 @@ EXTRA_OECMAKE += "-D_SwiftCollections_SourceDIR=${WORKDIR}/swift-collections" EXTRA_OECMAKE += "-DSwiftFoundation_MODULE_TRIPLE=${SWIFT_TARGET_NAME}" EXTRA_OECMAKE += "-DSwiftSyntax_DIR=${WORKDIR}/swift-syntax/cmake/modules" -lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" - # Ensure the right CPU is targeted cmake_do_generate_toolchain_file:append() { sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake diff --git a/recipes-devtools/swift/swift-foundation-icu.bb b/recipes-devtools/swift/swift-foundation-icu.bb index 98a5f5b..265a119 100644 --- a/recipes-devtools/swift/swift-foundation-icu.bb +++ b/recipes-devtools/swift/swift-foundation-icu.bb @@ -23,8 +23,6 @@ TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" -lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" - # Ensure the right CPU is targeted cmake_do_generate_toolchain_file:append() { sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake diff --git a/recipes-devtools/swift/swift-foundation.bb b/recipes-devtools/swift/swift-foundation.bb index 813495d..912e285 100644 --- a/recipes-devtools/swift/swift-foundation.bb +++ b/recipes-devtools/swift/swift-foundation.bb @@ -43,8 +43,6 @@ EXTRA_OECMAKE += "-DENABLE_TESTING=0" EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" EXTRA_OECMAKE += "-DDISPATCH_INCLUDE_PATH=${STAGING_DIR_TARGET}/${includedir}" -lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" - # Ensure the right CPU is targeted cmake_do_generate_toolchain_file:append() { sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake From 2489fc4b626801f95f45a054a14abd8103e6ef5c Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 16:08:30 +1000 Subject: [PATCH 32/41] swift-testing: fix _FORTIFY_SOURCE build `limits.h` must be included before `stdlib.h` when building with glibc and having `_FORTIFY_SOURCE` set to a non-zero value. When building with `_FORTIFY_SOURCE`, `realpath()` is inlined, and its definition depends on whether `limits.h` has been included or not (clearly, this is a terrible idea in terms of interacting with Clang modules and should probably be fixed upstream). If the definition differs from the one in SwiftGlibc, then _TestingInternals will not build. swiftlang/swift-testing#1184 --- recipes-devtools/swift/swift-testing.bb | 1 + ...efore-stdlib.h-to-workaround-for-gli.patch | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch diff --git a/recipes-devtools/swift/swift-testing.bb b/recipes-devtools/swift/swift-testing.bb index 3ef267c..6c5493d 100644 --- a/recipes-devtools/swift/swift-testing.bb +++ b/recipes-devtools/swift/swift-testing.bb @@ -13,6 +13,7 @@ SRCREV_FORMAT = "swift_testing" SRC_URI = "git://github.com/swiftlang/swift-testing.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" SRC_URI += "file://0001-build-as-dynamic-library.patch;striplevel=1;" +SRC_URI += "file://0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch;striplevel=1;" S = "${WORKDIR}/git" B = "${WORKDIR}/build" diff --git a/recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch b/recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch new file mode 100644 index 0000000..4fc6072 --- /dev/null +++ b/recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch @@ -0,0 +1,42 @@ +From 2ee53c692f781dff38dcbabe819ecfe841841588 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 16:00:04 +1000 +Subject: [PATCH] order limits.h before stdlib.h to workaround for glibc + fortify source issue + +limits.h must be included before stdlib.h with glibc, otherwise the fortified +realpath() in this module's stdlib will differ from the one in SwiftGlibc. +--- + Sources/_TestingInternals/include/Includes.h | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/Sources/_TestingInternals/include/Includes.h b/Sources/_TestingInternals/include/Includes.h +index 1b95151..acc38df 100644 +--- a/Sources/_TestingInternals/include/Includes.h ++++ b/Sources/_TestingInternals/include/Includes.h +@@ -39,6 +39,11 @@ + #include + #include + #include ++#if __has_include() ++/// limits.h must be included before stdlib.h with glibc, otherwise the ++/// fortified realpath() in this module will differ from the one in SwiftGlibc. ++#include ++#endif + #include + #include + #include +@@ -97,10 +102,6 @@ + #include + #endif + +-#if __has_include() +-#include +-#endif +- + #if __has_include() + #include + #endif +-- +2.39.5 (Apple Git-154) + From 4dc02499a109cccc181a8aacc888e9f6966775f0 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 17:44:19 +1000 Subject: [PATCH 33/41] remove -mbranch-protection=standard from tune args compiling with -mbranch-protection=standard appears to cause a crash on aarch64 (at least, on my CM4); until this is further investigated, remove this from the tune args. --- classes/swift-cmake-base.bbclass | 2 ++ classes/swift.bbclass | 2 ++ 2 files changed, 4 insertions(+) diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index e14c646..701dbcc 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -3,6 +3,8 @@ inherit cmake # avoid conflicts with meta-clang TOOLCHAIN = "gcc" +TARGET_CC_ARCH:remove = "-mbranch-protection=standard" + DEPENDS:append = " swift-native libgcc gcc glibc " SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 9e8c4dc..26a88f8 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -1,6 +1,8 @@ # avoid conflicts with meta-clang TOOLCHAIN = "gcc" +TARGET_CC_ARCH:remove = "-mbranch-protection=standard" + SWIFT_BUILD_TESTS ?= "${DEBUG_BUILD}" DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch swift-foundation" From 9a336235ae7a7e2ab6938d93529069eed07a91cb Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 19:09:04 +1000 Subject: [PATCH 34/41] move CMake/SwiftPM common variables into swift-common.bbclass --- classes/swift-cmake-base.bbclass | 8 ++------ classes/swift-cmake.bbclass | 2 +- classes/swift-common.bbclass | 5 +++++ classes/swift.bbclass | 9 +++------ 4 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 classes/swift-common.bbclass diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 701dbcc..b1a2d2f 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -1,11 +1,7 @@ inherit cmake +inherit swift-common -# avoid conflicts with meta-clang -TOOLCHAIN = "gcc" - -TARGET_CC_ARCH:remove = "-mbranch-protection=standard" - -DEPENDS:append = " swift-native libgcc gcc glibc " +DEPENDS:append = " swift-native libgcc gcc glibc" SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" diff --git a/classes/swift-cmake.bbclass b/classes/swift-cmake.bbclass index 79f0643..c508fab 100644 --- a/classes/swift-cmake.bbclass +++ b/classes/swift-cmake.bbclass @@ -1,5 +1,5 @@ inherit swift-cmake-base -DEPENDS:append = "swift-stdlib libdispatch swift-foundation" +DEPENDS:append = " swift-stdlib libdispatch swift-foundation" TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" diff --git a/classes/swift-common.bbclass b/classes/swift-common.bbclass new file mode 100644 index 0000000..cb6ab9e --- /dev/null +++ b/classes/swift-common.bbclass @@ -0,0 +1,5 @@ +# avoid conflicts with meta-clang +TOOLCHAIN = "gcc" + +# appears to cause segfault +TARGET_CC_ARCH:remove:aarch64 = "-mbranch-protection=standard" diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 26a88f8..22c796c 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -1,12 +1,9 @@ -# avoid conflicts with meta-clang -TOOLCHAIN = "gcc" - -TARGET_CC_ARCH:remove = "-mbranch-protection=standard" +inherit swift-common SWIFT_BUILD_TESTS ?= "${DEBUG_BUILD}" -DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch swift-foundation" -DEPENDS += "${@oe.utils.conditional('SWIFT_BUILD_TESTS', '1', 'swift-xctest swift-testing', '', d)}" +DEPENDS:append = " swift-native glibc gcc libgcc swift-stdlib libdispatch swift-foundation" +DEPENDS:append = " ${@oe.utils.conditional('SWIFT_BUILD_TESTS', '1', ' swift-xctest swift-testing', '', d)}" # Default build directory for SPM is "./.build" # (see 'swift [build|package|run|test] --help') From b4292fcb07bb09e79b4d2dc8e4a3fb2933c1d9eb Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 28 Jun 2025 21:32:18 +1000 Subject: [PATCH 35/41] workaround for building on x86_64: disable SSE SSE appears to cause cyclic header dependency when building C++ std module. This needs investigation and an upstream fix. --- classes/swift-common.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/swift-common.bbclass b/classes/swift-common.bbclass index cb6ab9e..c276c68 100644 --- a/classes/swift-common.bbclass +++ b/classes/swift-common.bbclass @@ -3,3 +3,11 @@ TOOLCHAIN = "gcc" # appears to cause segfault TARGET_CC_ARCH:remove:aarch64 = "-mbranch-protection=standard" + +# workaround for building on x86_64: SSE appears to cause cyclic header +# dependency when building C++ std module. This needs investigation and an +# upstream fix +TARGET_CC_ARCH:remove:x86-64 = "-march=core2" +TARGET_CC_ARCH:remove:x86-64 = "-mtune=core2" +TARGET_CC_ARCH:remove:x86-64 = "-msse3" +TARGET_CC_ARCH:remove:x86-64 = "-mfpmath=sse" From e9688836eec3b89eba5cfd7337b7a03e3ffa8e00 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 29 Jun 2025 11:14:55 +1000 Subject: [PATCH 36/41] completely disable 64-bit time_t on 32-bit systems This overrides the Yocto default and may cause your program to crash if Swift packages link against other packages that do not have this disabled. Caveat emptor. --- classes/swift-common.bbclass | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/classes/swift-common.bbclass b/classes/swift-common.bbclass index c276c68..ed87971 100644 --- a/classes/swift-common.bbclass +++ b/classes/swift-common.bbclass @@ -1,6 +1,11 @@ # avoid conflicts with meta-clang TOOLCHAIN = "gcc" +# force disable GLIBC_64BIT_TIME_FLAGS until SwiftNIO and other common packages +# are updated to support 64-bit time_t on 32-bit systems. ABI incompatibility +# may cause your program to crash; you have been warned. +TARGET_CC_ARCH:remove:arm = "${GLIBC_64BIT_TIME_FLAGS}" + # appears to cause segfault TARGET_CC_ARCH:remove:aarch64 = "-mbranch-protection=standard" From 2299aabd03818d15889d9a98a51d7017958c401c Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 30 Jun 2025 13:05:18 +1000 Subject: [PATCH 37/41] consolidate common variables between CMake and SwiftPM classes in the interest of DRY, consolidate common variables between CMake and SwiftPM classes, moving per-architecture tune flags into a new class (swift-platform-tune.bbclass) --- classes/swift-cmake-base.bbclass | 25 +++++++------------------ classes/swift-common.bbclass | 21 ++++++++------------- classes/swift-target-tune.bbclass | 15 +++++++++++++++ classes/swift.bbclass | 8 +------- 4 files changed, 31 insertions(+), 38 deletions(-) create mode 100644 classes/swift-target-tune.bbclass diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index b1a2d2f..856dc55 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -1,15 +1,9 @@ inherit cmake inherit swift-common -DEPENDS:append = " swift-native libgcc gcc glibc" - -SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" -SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" -TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', '${TARGET_ARCH}', d)}" - -# Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key -# RECIPE_MAINTAINER:pn-gcc-source- python () { + # Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key + # RECIPE_MAINTAINER:pn-gcc-source- import shlex gcc_src_maint_pkg = [x for x in d if x.startswith("RECIPE_MAINTAINER:pn-gcc-source-")][0] @@ -74,8 +68,11 @@ SWIFTC_BIN = "${STAGING_DIR_NATIVE}/usr/bin/swiftc" EXTRA_OECMAKE:append = " -DCMAKE_Swift_COMPILER=${SWIFTC_BIN}" EXTRA_OECMAKE:append = " -DCMAKE_SWIFT_COMPILER=${SWIFTC_BIN}" - -BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" +EXTRA_OECMAKE:append = ' -DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' +EXTRA_OECMAKE:append = " -DSWIFT_USE_LINKER=lld" +EXTRA_OECMAKE:append = " -DLLVM_USE_LINKER=lld" +EXTRA_OECMAKE:append = " -DLLVM_DIR=${HOST_LLVM_PATH}/cmake/llvm" +EXTRA_OECMAKE:append = " -DLLVM_BUILD_LIBRARY_DIR=${HOST_LLVM_PATH}" # Additional parameters to pass to swiftc EXTRA_SWIFTC_FLAGS ??= "" @@ -99,11 +96,3 @@ SWIFT_FLAGS = "-target ${SWIFT_TARGET_NAME} -use-ld=lld \ " HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/usr/lib" - -EXTRA_OECMAKE:append = ' -DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' -EXTRA_OECMAKE:append = " -DSWIFT_USE_LINKER=lld" -EXTRA_OECMAKE:append = " -DLLVM_USE_LINKER=lld" -EXTRA_OECMAKE:append = " -DLLVM_DIR=${HOST_LLVM_PATH}/cmake/llvm" -EXTRA_OECMAKE:append = " -DLLVM_BUILD_LIBRARY_DIR=${HOST_LLVM_PATH}" - -EXTRANATIVEPATH:append = " swift-tools" diff --git a/classes/swift-common.bbclass b/classes/swift-common.bbclass index ed87971..bd5d1c1 100644 --- a/classes/swift-common.bbclass +++ b/classes/swift-common.bbclass @@ -1,18 +1,13 @@ # avoid conflicts with meta-clang TOOLCHAIN = "gcc" -# force disable GLIBC_64BIT_TIME_FLAGS until SwiftNIO and other common packages -# are updated to support 64-bit time_t on 32-bit systems. ABI incompatibility -# may cause your program to crash; you have been warned. -TARGET_CC_ARCH:remove:arm = "${GLIBC_64BIT_TIME_FLAGS}" +DEPENDS:append = " swift-native glibc gcc libgcc" +EXTRANATIVEPATH:append = " swift-tools" -# appears to cause segfault -TARGET_CC_ARCH:remove:aarch64 = "-mbranch-protection=standard" +SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" +SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" +TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', '${TARGET_ARCH}', d)}" -# workaround for building on x86_64: SSE appears to cause cyclic header -# dependency when building C++ std module. This needs investigation and an -# upstream fix -TARGET_CC_ARCH:remove:x86-64 = "-march=core2" -TARGET_CC_ARCH:remove:x86-64 = "-mtune=core2" -TARGET_CC_ARCH:remove:x86-64 = "-msse3" -TARGET_CC_ARCH:remove:x86-64 = "-mfpmath=sse" +BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" + +inherit swift-target-tune diff --git a/classes/swift-target-tune.bbclass b/classes/swift-target-tune.bbclass new file mode 100644 index 0000000..451b4a7 --- /dev/null +++ b/classes/swift-target-tune.bbclass @@ -0,0 +1,15 @@ +# force disable GLIBC_64BIT_TIME_FLAGS until SwiftNIO and other common packages +# are updated to support 64-bit time_t on 32-bit systems. ABI incompatibility +# may cause your program to crash; you have been warned. +TARGET_CC_ARCH:remove:arm = "${GLIBC_64BIT_TIME_FLAGS}" + +# appears to cause segfault +TARGET_CC_ARCH:remove:aarch64 = "-mbranch-protection=standard" + +# workaround for building on x86_64: SSE appears to cause cyclic header +# dependency when building C++ std module. This needs investigation and an +# upstream fix +TARGET_CC_ARCH:remove:x86-64 = "-march=core2" +TARGET_CC_ARCH:remove:x86-64 = "-mtune=core2" +TARGET_CC_ARCH:remove:x86-64 = "-msse3" +TARGET_CC_ARCH:remove:x86-64 = "-mfpmath=sse" diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 22c796c..b7d281f 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -2,7 +2,7 @@ inherit swift-common SWIFT_BUILD_TESTS ?= "${DEBUG_BUILD}" -DEPENDS:append = " swift-native glibc gcc libgcc swift-stdlib libdispatch swift-foundation" +DEPENDS:append = " swift-stdlib libdispatch swift-foundation" DEPENDS:append = " ${@oe.utils.conditional('SWIFT_BUILD_TESTS', '1', ' swift-xctest swift-testing', '', d)}" # Default build directory for SPM is "./.build" @@ -13,15 +13,11 @@ DEPENDS:append = " ${@oe.utils.conditional('SWIFT_BUILD_TESTS', '1', ' swift-xct B ?= "${S}/.build" EXTERNALSRC_BUILD ?= "${EXTERNALSRC}/.build" -BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" BUILD_DIR = "${B}/${BUILD_MODE}" # Additional parameters to pass to SPM EXTRA_OESWIFT ?= "" -SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" -SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" - do_fix_gcc_install_dir() { # symbolic links do not work, will not be found by Swift clang driver # this is necessary to make the libstdc++ location heuristic work, necessary for C++ interop @@ -272,5 +268,3 @@ do_package_update[network] = "1" addtask do_package_update after do_configure EXPORT_FUNCTIONS do_configure do_compile do_package_update - -EXTRANATIVEPATH += "swift-tools" From a6e7ac29883c185017f439ae01d228ca3fc39b27 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 30 Jun 2025 13:33:00 +1000 Subject: [PATCH 38/41] use common ${SWIFT_TAG} variable replace swift-${SWIFT_VERSION}-RELEASE with ${SWIFT_TAG}; this should make it easier to test pre-release versions of Swift --- recipes-devtools/swift/libdispatch.bb | 2 +- recipes-devtools/swift/swift-foundation-essentials.bb | 6 +++--- recipes-devtools/swift/swift-foundation-icu.bb | 2 +- recipes-devtools/swift/swift-foundation.bb | 8 ++++---- recipes-devtools/swift/swift-native.bb | 4 ++-- recipes-devtools/swift/swift-stdlib.bb | 10 +++++----- recipes-devtools/swift/swift-testing.bb | 2 +- recipes-devtools/swift/swift-version.inc | 1 + recipes-devtools/swift/swift-xctest.bb | 2 +- 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/recipes-devtools/swift/libdispatch.bb b/recipes-devtools/swift/libdispatch.bb index e1ef882..5d7e0c5 100644 --- a/recipes-devtools/swift/libdispatch.bb +++ b/recipes-devtools/swift/libdispatch.bb @@ -10,7 +10,7 @@ PV = "${SWIFT_VERSION}+git${SRCPV}" DEPENDS = "swift-stdlib" -SRC_URI = "git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" +SRC_URI = "git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;tag=${SWIFT_TAG};nobranch=1" S = "${WORKDIR}/git" LIBDISPATCH_BUILDDIR = "${WORKDIR}/build" diff --git a/recipes-devtools/swift/swift-foundation-essentials.bb b/recipes-devtools/swift/swift-foundation-essentials.bb index 4eba0af..f6c4e20 100644 --- a/recipes-devtools/swift/swift-foundation-essentials.bb +++ b/recipes-devtools/swift/swift-foundation-essentials.bb @@ -9,9 +9,9 @@ require swift-version.inc PV = "${SWIFT_VERSION}+git${SRCPV}" SRCREV_FORMAT = "foundation_icu_syntax_collections" -SRC_URI = "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;" -SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" -SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI = "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=${SWIFT_TAG};nobranch=1;" +SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation-icu;" SRC_URI += "git://github.com/apple/swift-collections.git;protocol=https;nobranch=1;name=collections;tag=1.1.4;destsuffix=swift-collections;" SRC_URI += "file://0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch;striplevel=1;" SRC_URI += "file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1;" diff --git a/recipes-devtools/swift/swift-foundation-icu.bb b/recipes-devtools/swift/swift-foundation-icu.bb index 265a119..15225ed 100644 --- a/recipes-devtools/swift/swift-foundation-icu.bb +++ b/recipes-devtools/swift/swift-foundation-icu.bb @@ -8,7 +8,7 @@ LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2380e856fbdbc7ccae6bd699d53ec121" require swift-version.inc PV = "${SWIFT_VERSION}+git${SRCPV}" -SRC_URI = "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;" +SRC_URI = "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=${SWIFT_TAG};nobranch=1;" S = "${WORKDIR}/git" diff --git a/recipes-devtools/swift/swift-foundation.bb b/recipes-devtools/swift/swift-foundation.bb index 912e285..470e5d9 100644 --- a/recipes-devtools/swift/swift-foundation.bb +++ b/recipes-devtools/swift/swift-foundation.bb @@ -9,10 +9,10 @@ require swift-version.inc PV = "${SWIFT_VERSION}+git${SRCPV}" SRCREV_FORMAT = "corelibs_foundation_icu_syntax" -SRC_URI = "git://github.com/swiftlang/swift-corelibs-foundation.git;protocol=https;name=corelibs;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;" -SRC_URI += "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation;" -SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-foundation-icu;" -SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax;" +SRC_URI = "git://github.com/swiftlang/swift-corelibs-foundation.git;protocol=https;name=corelibs;tag=${SWIFT_TAG};nobranch=1;" +SRC_URI += "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation;" +SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-syntax;" SRC_URI += "file://0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch;striplevel=1;" SRC_URI += "file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1;" diff --git a/recipes-devtools/swift/swift-native.bb b/recipes-devtools/swift/swift-native.bb index 604045b..97e5fd6 100644 --- a/recipes-devtools/swift/swift-native.bb +++ b/recipes-devtools/swift/swift-native.bb @@ -27,8 +27,8 @@ SWIFT_ARCH_SUFFIX = "${@swift_native_arch_suffix(d)}" SWIFT_LINUX_DISTRO = "amazonlinux2" -SRC_DIR = "swift-${SWIFT_VERSION}-RELEASE-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}" -SRC_URI = "https://download.swift.org/swift-${SWIFT_VERSION}-release/${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}.tar.gz" +SRC_DIR = "${SWIFT_TAG}-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}" +SRC_URI = "https://download.swift.org/swift-${SWIFT_VERSION}-release/${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}/${SWIFT_TAG}/${SWIFT_TAG}-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}.tar.gz" SRC_URI[sha256sum] = "${@swift_native_arch_checksum(d)}" DEPENDS = "curl" diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index df49a4a..6a7bbda 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -12,11 +12,11 @@ PV = "${SWIFT_VERSION}+git${SRCPV}" SRCREV_FORMAT = "swift_libdispatch_stringproc_syntax" SRC_URI = "\ - git://github.com/swiftlang/llvm-project.git;protocol=https;name=llvm-project;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=llvm-project; \ - git://github.com/swiftlang/swift.git;protocol=https;name=swift;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift; \ - git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;name=libdispatch;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=libdispatch; \ - git://github.com/swiftlang/swift-experimental-string-processing.git;protocol=https;name=stringproc;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-experimental-string-processing; \ - git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1;destsuffix=swift-syntax; \ + git://github.com/swiftlang/llvm-project.git;protocol=https;name=llvm-project;tag=${SWIFT_TAG};nobranch=1;destsuffix=llvm-project; \ + git://github.com/swiftlang/swift.git;protocol=https;name=swift;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift; \ + git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;name=libdispatch;tag=${SWIFT_TAG};nobranch=1;destsuffix=libdispatch; \ + git://github.com/swiftlang/swift-experimental-string-processing.git;protocol=https;name=stringproc;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-experimental-string-processing; \ + git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-syntax; \ file://0001-add-arm-to-float16support-for-armv7.patch;striplevel=1; \ file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1; \ " diff --git a/recipes-devtools/swift/swift-testing.bb b/recipes-devtools/swift/swift-testing.bb index 6c5493d..cf84ebb 100644 --- a/recipes-devtools/swift/swift-testing.bb +++ b/recipes-devtools/swift/swift-testing.bb @@ -11,7 +11,7 @@ require swift-version.inc PV = "${SWIFT_VERSION}+git${SRCPV}" SRCREV_FORMAT = "swift_testing" -SRC_URI = "git://github.com/swiftlang/swift-testing.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" +SRC_URI = "git://github.com/swiftlang/swift-testing.git;protocol=https;tag=${SWIFT_TAG};nobranch=1" SRC_URI += "file://0001-build-as-dynamic-library.patch;striplevel=1;" SRC_URI += "file://0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch;striplevel=1;" diff --git a/recipes-devtools/swift/swift-version.inc b/recipes-devtools/swift/swift-version.inc index 70a1477..eda5f1b 100644 --- a/recipes-devtools/swift/swift-version.inc +++ b/recipes-devtools/swift/swift-version.inc @@ -1 +1,2 @@ SWIFT_VERSION = "6.1.2" +SWIFT_TAG = "swift-${SWIFT_VERSION}-RELEASE" diff --git a/recipes-devtools/swift/swift-xctest.bb b/recipes-devtools/swift/swift-xctest.bb index f7ff4ea..4b69453 100644 --- a/recipes-devtools/swift/swift-xctest.bb +++ b/recipes-devtools/swift/swift-xctest.bb @@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" require swift-version.inc PV = "${SWIFT_VERSION}+git${SRCPV}" -SRC_URI = "git://github.com/swiftlang/swift-corelibs-xctest.git;protocol=https;tag=swift-${SWIFT_VERSION}-RELEASE;nobranch=1" +SRC_URI = "git://github.com/swiftlang/swift-corelibs-xctest.git;protocol=https;tag=${SWIFT_TAG};nobranch=1" S = "${WORKDIR}/git" B = "${WORKDIR}/build" From dbd89c440487be09ad80fe0d039f9fc526556963 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 1 Jul 2025 15:51:02 +1000 Subject: [PATCH 39/41] don't set both -enforce-exclusivity=unchecked and none Exclusivity checking has high runtime performance cost, which is undesirable for embedded systems. Specifying both options doesn't make sense; opt for -enforce-exclusivity=unchecked which retains static analysis but disables runtime checking. [1] [1] https://www.swift.org/blog/swift-5-exclusivity/ --- classes/swift.bbclass | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/swift.bbclass b/classes/swift.bbclass index b7d281f..4352832 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -150,7 +150,6 @@ python swift_do_configure() { "${STAGING_DIR_NATIVE}/usr/bin", "-enforce-exclusivity=unchecked", - "-enforce-exclusivity=none", "-Xlinker", "-rpath", "-Xlinker", "/usr/lib/swift/linux", From a9e0cbe982e66e4408f9e57da60a1da2a6fecf38 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 1 Jul 2025 16:22:11 +1000 Subject: [PATCH 40/41] allow Swift package resolution to be wrapped by recipes export the Swift package resolution function as do_package_resolve so it can be used conditionally from recipes --- classes/swift.bbclass | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 4352832..111f329 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -50,11 +50,11 @@ def fix_socket_header(filename): f.write(line) # Support for SwiftPM fetching packages and their GitHub submodules -do_swift_package_resolve[depends] += "unzip-native:do_populate_sysroot swift-native:do_populate_sysroot" -do_swift_package_resolve[network] = "1" -do_swift_package_resolve[vardepsexclude] = "BB_ORIGENV" +swift_do_package_resolve[depends] += "unzip-native:do_populate_sysroot swift-native:do_populate_sysroot" +swift_do_package_resolve[network] = "1" +swift_do_package_resolve[vardepsexclude] = "BB_ORIGENV" -python do_swift_package_resolve() { +python swift_do_package_resolve() { import subprocess import os @@ -79,7 +79,7 @@ python do_swift_package_resolve() { bb.fatal('git submodule update failed') } -addtask swift_package_resolve after do_unpack before do_compile +addtask do_package_resolve after do_unpack before do_compile python swift_do_configure() { import os @@ -205,7 +205,7 @@ python swift_do_configure() { configJSON.close() } -# ideally this should be handled by do_swift_package_resolve but doesn't always appear to be the case +# ideally this should be handled by swift_do_package_resolve but doesn't always appear to be the case do_compile[network] = "1" swift_do_compile[vardepsexclude] = "BB_ORIGENV" @@ -266,4 +266,4 @@ do_package_update() { do_package_update[network] = "1" addtask do_package_update after do_configure -EXPORT_FUNCTIONS do_configure do_compile do_package_update +EXPORT_FUNCTIONS do_package_resolve do_configure do_compile do_package_update From 55501beb4027932c754ccebc90cb75a353bb888c Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 1 Jul 2025 17:36:35 +1000 Subject: [PATCH 41/41] call swift driver with absolute path --- classes/swift.bbclass | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/swift.bbclass b/classes/swift.bbclass index 111f329..ecefb81 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -60,6 +60,7 @@ python swift_do_package_resolve() { s = d.getVar('S') b = d.getVar('B') + recipe_sysroot_native = d.getVar("STAGING_DIR_NATIVE", True) env = os.environ.copy() @@ -67,7 +68,7 @@ python swift_do_package_resolve() { if ssh_auth_sock: env['SSH_AUTH_SOCK'] = ssh_auth_sock - ret = subprocess.call(['swift', 'package', 'resolve', '--package-path', s, '--build-path', b], env=env) + ret = subprocess.call([f'{recipe_sysroot_native}/usr/bin/swift', 'package', 'resolve', '--package-path', s, '--build-path', b], env=env) if ret != 0: bb.fatal('swift package resolve failed') @@ -222,13 +223,14 @@ python swift_do_compile() { extra_oeswift = shlex.split(d.getVar('EXTRA_OESWIFT')) ssh_auth_sock = d.getVar('BB_ORIGENV').get('SSH_AUTH_SOCK') recipe_sysroot = d.getVar("STAGING_DIR_TARGET", True) + recipe_sysroot_native = d.getVar("STAGING_DIR_NATIVE", True) env = os.environ.copy() if ssh_auth_sock: env['SSH_AUTH_SOCK'] = ssh_auth_sock env['SYSROOT'] = recipe_sysroot - args = ['swift', 'build', '--package-path', s, '--build-path', b, '-c', build_mode, '--destination', destination_json] + extra_oeswift + args = [f'{recipe_sysroot_native}/usr/bin/swift', 'build', '--package-path', s, '--build-path', b, '-c', build_mode, '--destination', destination_json] + extra_oeswift ret = subprocess.call(args, env=env, cwd=s) if ret != 0: