@@ -9,6 +9,23 @@ SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aar
99SWIFT_TARGET_NAME = "${@ oe . utils . conditional ('TARGET_ARCH' , 'arm' , 'armv7-unknown-linux-gnueabihf' , 'aarch64-unknown-linux-gnu' , d )}"
1010TARGET_CPU_NAME = "${@ oe . utils . conditional ('TARGET_ARCH' , 'arm' , 'armv7-a' , 'aarch64' , d )}"
1111
12+ # Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key
13+ # RECIPE_MAINTAINER:pn-gcc-source-<version>
14+ python () {
15+ gcc_src_maint_pkg = [x for x in d if x . startswith ("RECIPE_MAINTAINER:pn-gcc-source-" )][0 ]
16+ gcc_ver = gcc_src_maint_pkg . rpartition ("-" )[2 ]
17+
18+ d . setVar ("SWIFT_GCC_VERSION" , gcc_ver )
19+ }
20+
21+ EXTRA_INCLUDE_FLAGS ?= "\
22+ -I${STAGING_DIR_TARGET} /usr/include/c++/${SWIFT_GCC_VERSION} /${TARGET_SYS} \
23+ -I${STAGING_DIR_TARGET} /usr/include/c++/${SWIFT_GCC_VERSION} \
24+ -I${STAGING_DIR_TARGET} "
25+
26+ # not supported by clang
27+ DEBUG_PREFIX_MAP :remove = "-fcanon-prefix-map"
28+
1229HOST_CC_ARCH :prepend = "-target ${SWIFT_TARGET_NAME} "
1330
1431# ###############################################################################
@@ -31,8 +48,8 @@ OECMAKE_C_COMPILER = "clang"
3148OECMAKE_CXX_COMPILER = "clang++"
3249
3350# Point clang to where the C++ runtime is for our target arch
34- RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /current "
35- TARGET_LDFLAGS + = "-w -fuse-ld=lld -L${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /current "
51+ RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /${SWIFT_GCC_VERSION} "
52+ TARGET_LDFLAGS : append = " -w -fuse-ld=lld -L${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /${SWIFT_GCC_VERSION} "
3653
3754OECMAKE_C_FLAGS :append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS} "
3855OECMAKE_CXX_FLAGS :append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS} "
@@ -67,45 +84,6 @@ ${EXTRA_SWIFTC_FLAGS} \
6784
6885HOST_LLVM_PATH = "${STAGING_DIR_NATIVE} /usr/lib"
6986
70- EXTRANATIVEPATH += "swift-tools"
71-
72- # ###############################################################################
73- # Create symlinks to the directories containing the gcc version specific #
74- # headers, objects and libraries we need. #
75- # #
76- # We can't just use ${GCC_VERSION} in the path variables in the recipe #
77- # because bitbake parses and expands variables before GCC_VERSION is #
78- # defined. GCC_VERSION cannot be defined until the sysroot is populated #
79- # because we inspect the sysroot to determine the GCC version number string. #
80- # If there was an env or bitbake var with the GCC version, we could use that #
81- # and avoid all of this but the closest thing we have access to is #
82- # ${GCCVERSION} which yields and incomplete version number (ex: "9.%"). #
83- # #
84- # Also there is some suspicion that these path variables and these symlinks #
85- # may not be necessary if the --gcc-toolchain clang flag was used. But that #
86- # is an unproven theory. #
87- # ###############################################################################
88-
89- do_create_gcc_version_symlinks () {
90- GCC_VERSION = `basename ${STAGING_DIR_TARGET} /usr /include /c ++/*`
91-
92- if [ ! -L "${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /current" ]; then
93- cd ${STAGING_DIR_TARGET} /usr /lib /${TARGET_SYS}
94- ln -s -r ${GCC_VERSION} current
95- fi
96-
97- if [ ! -L "${STAGING_DIR_TARGET} /usr/include/c++/current" ]; then
98- cd ${STAGING_DIR_TARGET} /usr /include /c ++
99- ln -s -r ${GCC_VERSION} current
100- fi
101-
102- if [ ! -L "${STAGING_DIR_NATIVE} /usr/lib/${TARGET_SYS} /gcc/${TARGET_SYS} /current" ]; then
103- cd ${STAGING_DIR_NATIVE} /usr /lib /${TARGET_SYS} /gcc /${TARGET_SYS}
104- ln -s -r ${GCC_VERSION} current
105- fi
106- }
107-
108- addtask do_create_gcc_version_symlinks after do_prepare_recipe_sysroot before do_configure
10987EXTRA_OECMAKE :append = ' -DCMAKE_Swift_FLAGS="${SWIFT_FLAGS} "'
11088EXTRA_OECMAKE :append = " -DSWIFT_USE_LINKER=lld"
11189EXTRA_OECMAKE :append = " -DLLVM_USE_LINKER=lld"
0 commit comments