diff options
| author | Ross Burton <ross.burton@arm.com> | 2025-09-26 15:33:39 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-01 10:52:54 +0100 |
| commit | 844539e848e4ff40e0ace3cf871ee53232790d8f (patch) | |
| tree | 30a076a7bcd15ea3b6a3d68b196070a61758cf0c | |
| parent | fb086f85b7959e2bac3466b26881e8eab03f2858 (diff) | |
| download | poky-844539e848e4ff40e0ace3cf871ee53232790d8f.tar.gz | |
classes/cmake: unset LDFLAGS in toolchain-native.bbclass
If a recipe is using toolchain-native.cmake to build native portion in a
non-native build, the target LDFLAGS from the environment will leak into
the native build.
This was noticed as building a SDK with clang means that LDFLAGS contains
a --dynamic-loader argument, so native binaries were trying to use the
target loader.
There are several variables that are set from LDFLAGS[1] so instead of
setting them all, we can simply unset the environment variable in the
toolchain.
[1] https://cmake.org/cmake/help/latest/envvar/LDFLAGS.html
(From OE-Core rev: f9fa240a6788188174c8080a78018ed9ce402f54)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/classes-recipe/cmake.bbclass | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/meta/classes-recipe/cmake.bbclass b/meta/classes-recipe/cmake.bbclass index b8cd622c2d..4f59966521 100644 --- a/meta/classes-recipe/cmake.bbclass +++ b/meta/classes-recipe/cmake.bbclass | |||
| @@ -212,6 +212,15 @@ set( CMAKE_LIBRARY_PATH ${STAGING_BASE_LIBDIR_NATIVE} ${STAGING_LIBDIR_NATIVE}) | |||
| 212 | list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${STAGING_INCDIR_NATIVE}) | 212 | list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${STAGING_INCDIR_NATIVE}) |
| 213 | list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${STAGING_INCDIR_NATIVE}) | 213 | list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${STAGING_INCDIR_NATIVE}) |
| 214 | 214 | ||
| 215 | # The assignmens above override CFLAGS and CXXFLAGS from the environment but | ||
| 216 | # not LDFLAGS, which ends up in CMAKE_EXE_LINKER_FLAGS. This then means our | ||
| 217 | # native builds use target flags, and can fail. | ||
| 218 | # | ||
| 219 | # As there are a number of variables that are set from LDFLAGS, | ||
| 220 | # clear it at source. | ||
| 221 | # | ||
| 222 | # https://cmake.org/cmake/help/latest/envvar/LDFLAGS.html | ||
| 223 | unset(ENV{LDFLAGS}) | ||
| 215 | EOF | 224 | EOF |
| 216 | } | 225 | } |
| 217 | 226 | ||
