Skip to content

Why does Meson not automatically find the strip binary when cross-building? #14172

@uilianries

Description

@uilianries

Hello team!

First I would like to thank you all for providing such a nice build tool, which is getting ever more popular.

I’ve noticed a behavior in Meson that seems divergent from other build systems like CMake and Autotools. I know they are different projects and may have different proposals.

When cross-building a project, Meson does not automatically find the strip binary, even though it warns about strip not being found, like this:

WARNING: Cross file does not specify strip binary, result will not be stripped.

This requires explicitly specifying the strip binary in the cross file or via the environment STRIP=, which can be inconvenient.

In contrast, both CMake and Autotools automatically deduce and locate the appropriate strip binary for the target architecture during cross-compilation, because they use the triplet (compiler prefix) for it. This makes the process smoother and requires less manual configuration.

For instance, using CMake, I only set the compiler path and target architecture for my toolchain, like this:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER /opt/arm-gnu-toolchain-13/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /opt/arm-gnu-toolchain-13/bin/aarch64-none-linux-gnu-g++)

set(CMAKE_FIND_ROOT_PATH /opt/arm-gnu-toolchain-13)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Then, I run the CMake setup as usual:

cmake -S . -B build/ -DCMAKE_TOOLCHAIN_FILE=aarch64-toolchain.cmake

-- The CXX compiler identification is GNU 13.3.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/arm-gnu-toolchain-13/bin/aarch64-none-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/cmake-cross/build

Now, checking my CMake cache file, it lists the strip executable automatically found as well:

grep strip build/CMakeCache.txt 
CMAKE_STRIP:FILEPATH=/opt/arm-gnu-toolchain-13/bin/aarch64-none-linux-gnu-strip

Of course, I can override the strip path as well, but that's not the case.

This issue may be related to #13755 as well.


Could you clarify why Meson diverges from this behavior?
Is it something that could be improved in future versions?

Thank you for your time and for this great project!

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions