Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions generate-clang-meson-cross-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ toolchain_dest="${2}"
# Remaining cflags for build configurations
toolchain_cflags=("${@:3}")

# Clang requires a `--gcc-toolchain=<path>` 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=<path>` 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

Expand Down Expand Up @@ -62,15 +67,19 @@ 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'

[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]
Expand Down
18 changes: 12 additions & 6 deletions generate-gcc-meson-cross-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -61,15 +63,19 @@ 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'

[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]
Expand Down