diff --git a/generate-clang-meson-cross-file.sh b/generate-clang-meson-cross-file.sh index 3c888b4..cef9375 100755 --- a/generate-clang-meson-cross-file.sh +++ b/generate-clang-meson-cross-file.sh @@ -26,13 +26,18 @@ toolchain_dest="${2}" # Remaining cflags for build configurations toolchain_cflags=("${@:3}") -# Clang requires a `--gcc-toolchain=` argument to find some things -meson_cflags="'--gcc-toolchain=${toolchain_dest}'" +# Meson uses the driver when both compiling and linking, which may need flags to +# identify exactly how to set up paths and defaults for both. +# +# In particular, the clang driver requires a `--gcc-toolchain=` argument +# to find the right libraries if there are system versions of the risc-v +# toolchains installed. +meson_driver_flags="'--gcc-toolchain=${toolchain_dest}'" for flag in "${toolchain_cflags[@]}"; do - if [ -z "${meson_cflags}" ]; then - meson_cflags+="'${flag}'"; + if [ -z "${meson_driver_flags}" ]; then + meson_driver_flags+="'${flag}'"; else - meson_cflags+=", '${flag}'" + meson_driver_flags+=", '${flag}'" fi done @@ -62,6 +67,8 @@ c = '${toolchain_dest}/bin/${toolchain_target}-clang' cpp = '${toolchain_dest}/bin/${toolchain_target}-clang++' ar = '${toolchain_dest}/bin/${toolchain_target}-ar' ld = '${toolchain_dest}/bin/${toolchain_target}-ld' +c_ld = '${toolchain_dest}/bin/${toolchain_target}-ld' +cpp_ld = '${toolchain_dest}/bin/${toolchain_target}-ld' objdump = '${toolchain_dest}/bin/${toolchain_target}-objdump' objcopy = '${toolchain_dest}/bin/${toolchain_target}-objcopy' strip = '${toolchain_dest}/bin/${toolchain_target}-strip' @@ -69,8 +76,10 @@ strip = '${toolchain_dest}/bin/${toolchain_target}-strip' [properties] needs_exe_wrapper = true has_function_printf = false -c_args = [${meson_cflags}] -cpp_args = [${meson_cflags}] +c_args = [${meson_driver_flags}] +c_link_args = [${meson_driver_flags}] +cpp_args = [${meson_driver_flags}] +cpp_link_args = [${meson_driver_flags}] ${sysroot_config} [host_machine] diff --git a/generate-gcc-meson-cross-file.sh b/generate-gcc-meson-cross-file.sh index a050491..a36dc97 100755 --- a/generate-gcc-meson-cross-file.sh +++ b/generate-gcc-meson-cross-file.sh @@ -26,12 +26,14 @@ toolchain_dest="${2}" # Remaining cflags for build configurations toolchain_cflags=("${@:3}") -meson_cflags="" +# Meson uses the driver when both compiling and linking, which may need flags to +# identify exactly how to set up paths and defaults for both. +meson_driver_flags="" for flag in "${toolchain_cflags[@]}"; do - if [ -z "${meson_cflags}" ]; then - meson_cflags+="'${flag}'"; + if [ -z "${meson_driver_flags}" ]; then + meson_driver_flags+="'${flag}'"; else - meson_cflags+=", '${flag}'" + meson_driver_flags+=", '${flag}'" fi done @@ -61,6 +63,8 @@ c = '${toolchain_dest}/bin/${toolchain_target}-gcc' cpp = '${toolchain_dest}/bin/${toolchain_target}-g++' ar = '${toolchain_dest}/bin/${toolchain_target}-ar' ld = '${toolchain_dest}/bin/${toolchain_target}-ld' +c_ld = '${toolchain_dest}/bin/${toolchain_target}-ld' +cpp_ld = '${toolchain_dest}/bin/${toolchain_target}-ld' objdump = '${toolchain_dest}/bin/${toolchain_target}-objdump' objcopy = '${toolchain_dest}/bin/${toolchain_target}-objcopy' strip = '${toolchain_dest}/bin/${toolchain_target}-strip' @@ -68,8 +72,10 @@ strip = '${toolchain_dest}/bin/${toolchain_target}-strip' [properties] needs_exe_wrapper = true has_function_printf = false -c_args = [${meson_cflags}] -cpp_args = [${meson_cflags}] +c_args = [${meson_driver_flags}] +c_link_args = [${meson_driver_flags}] +cpp_args = [${meson_driver_flags}] +cpp_link_args = [${meson_driver_flags}] ${sysroot_config} [host_machine]