Different compiler for build targets inside a subdir #12183
-
Hi, is there any way to use a different compiler inside a subdir or for some selected build targets? Meson currently compiles all *.c files with same compiler. For an embedded application, I need some files to be compiled with a different compiler. Is this possible without separating code into a different project/subproject? Also, is there a way to 'compile' some C files and 'cross-compile' some other C files with a different compiler as part of same build process? That also will solve my usecase. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
You can definitely have different native and cross compiler. Targets that should be compiled for build machine should have |
Beta Was this translation helpful? Give feedback.
-
Meson enforces consistency at the "machine" level. Mixing and matching different compilers for the same language is forbidden at the generic level -- you can't build one program with amd64 GCC and the other with amd64 clang -- but specifically allowed as part of cross build support. See https://mesonbuild.com/Cross-compilation.html Cross compile builds need to be specifically set up with a toolchain (machine) file defining the cross-specific compiler. Build targets that need to be built for the build (native) machine as part of the same |
Beta Was this translation helpful? Give feedback.
Meson enforces consistency at the "machine" level. Mixing and matching different compilers for the same language is forbidden at the generic level -- you can't build one program with amd64 GCC and the other with amd64 clang -- but specifically allowed as part of cross build support.
See https://mesonbuild.com/Cross-compilation.html
Cross compile builds need to be specifically set up with a toolchain (machine) file defining the cross-specific compiler. Build targets that need to be built for the build (native) machine as part of the same
ninja
invocation will instead use$CC_FOR_BUILD
or whatever the default is on PATH.