target/hexagon: Fix macOS build
v2 cover target/hexagon: Fix macOS build
A default macOS build with xcode cli tools installed lacks the indent program needed by the idef-parser postprocess step. If indent is installed through homebrew it doesn't support the -linux flag. Conditionally run indent only on linux hosts.
Additionally cpp used by the idef-parser preprocess step expands into clang ... -traditional-cpp and doesn't support macro concatenation among other things, replace it with a meson custom_target running ${compiler} -E.
Note: default bison on macOS is still too old (v2.3 vs v3.0) and a newer version needs to be installed via homebrew. I'll take a look at supporting v2.3.
Changes in v2:
* Don't remove the indent step but only run on linux hosts.
Anton Johansson (2):
target/hexagon: Replace prepare script with meson target target/hexagon: Only indent on linux
target/hexagon/idef-parser/prepare | 24 ------------------------ target/hexagon/meson.build | 5 +++-- 2 files changed, 3 insertions(+), 26 deletions(-) delete mode 100755 target/hexagon/idef-parser/prepare
Signature · 1 line
2.47.1
PATCH v2 1/2 target/hexagon: Replace `prepare` script with meson target
The purpose of the prepare script is to invoke cpp to preprocess input to idef-parser by expanding a few select macros. On macOS cpp expands into clang ... -traditional-cpp which breaks macro concatenation. Replace cpp with ${compiler} -E
and replace the script with a meson custom_target.
--- target/hexagon/idef-parser/prepare | 24 ------------------------ target/hexagon/meson.build | 3 ++- 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100755 target/hexagon/idef-parser/prepare
target/hexagon/idef-parser/prepare deleted +0 -24
@@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright(c) 2019-2021 rev.ng Labs Srl. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. -# - -set -e -set -o pipefail - -# Run the preprocessor and drop comments -cpp "$@"
target/hexagon/meson.build +2 -1
@@ -280,12 +280,13 @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs command: [python, files('gen_idef_parser_funcs.py'), semantics_generated, '@OUTPUT@'], ) + compiler = meson.get_compiler('c').get_id() preprocessed_idef_parser_input_generated = custom_target( 'idef_parser_input.preprocessed.h.inc', output: 'idef_parser_input.preprocessed.h.inc', input: idef_parser_input_generated, depend_files: [idef_parser_dir / 'macros.h.inc'], - command: [idef_parser_dir / 'prepare', '@INPUT@', '-I' + idef_parser_dir, '-o', '@OUTPUT@'], + command: [compiler, '-x', 'c', '-E', '-I', idef_parser_dir, '-o', '@OUTPUT@', '@INPUT@'], ) flex = generator(
Signature · 1 line
2.47.1
Re: [PATCH v2 1/2] target/hexagon: Replace `prepare` script with meson target
Quoted 8 lines · Anton Johansson
The purpose of the prepare script is to invoke
cppto preprocess input to idef-parser by expanding a few select macros. On macOScppexpands intoclang ... -traditional-cppwhich breaks macro concatenation. Replacecppwith${compiler} -E
and replace the script with a mesoncustom_target.Signed-off-by Anton Johansson <[email protected]>---
Quoted 54 lines
target/hexagon/idef-parser/prepare | 24 ------------------------ target/hexagon/meson.build | 3 ++- 2 files changed, 2 insertions(+), 25 deletions(-)delete mode 100755 target/hexagon/idef-parser/prepare
target/hexagon/idef-parser/prepare deleted +0
-24@@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright(c) 2019-2021 rev.ng Labs Srl. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. -# - -set -e -set -o pipefail - -# Run the preprocessor and drop comments -cpp "$@"target/hexagon/meson.build +2
-1@@ -280,12 +280,13 @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs command: [python, files('gen_idef_parser_funcs.py'), semantics_generated, '@OUTPUT@'], ) + compiler = meson.get_compiler('c').get_id() preprocessed_idef_parser_input_generated = custom_target( 'idef_parser_input.preprocessed.h.inc', output: 'idef_parser_input.preprocessed.h.inc', input: idef_parser_input_generated, depend_files: [idef_parser_dir / 'macros.h.inc'], - command: [idef_parser_dir / 'prepare', '@INPUT@', '-I' + idef_parser_dir, '-o', '@OUTPUT@'], + command: [compiler, '-x', 'c', '-E', '-I', idef_parser_dir, '-o', '@OUTPUT@', '@INPUT@'], ) flex = generator(
PATCH v2 2/2 target/hexagon: Only indent on linux
In reply to Anton Johansson viaindent on macOS, installed via homebrew, doesn't support -linux. Only run indent on linux hosts.
--- target/hexagon/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/hexagon/meson.build +1 -1
@@ -324,7 +324,7 @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs ) indent = find_program('indent', required: false) - if indent.found() + if indent.found() and host_os == 'linux' idef_generated_tcg_c = custom_target( 'indent', input: idef_generated_tcg[0],
Signature · 1 line
2.47.1
Re: [PATCH v2 2/2] target/hexagon: Only indent on linux
Quoted 5 lines · Anton Johansson
indent on macOS, installed via homebrew, doesn't support -linux. Only run indent on linux hosts.
Signed-off-by Anton Johansson <[email protected]>---
Quoted 16 lines
target/hexagon/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/hexagon/meson.build +1
-1@@ -324,7 +324,7 @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs ) indent = find_program('indent', required: false) - if indent.found() + if indent.found() and host_os == 'linux' idef_generated_tcg_c = custom_target( 'indent', input: idef_generated_tcg[0],
Quoted 10 lines · Anton Johansson
A default macOS build with xcode cli tools installed lacks the
indentprogram needed by the idef-parser postprocess step. Ifindentis installed through homebrew it doesn't support the-linuxflag. Conditionally runindentonly on linux hosts.Additionally
cppused by the idef-parser preprocess step expands intoclang ... -traditional-cppand doesn't support macro concatenation among other things, replace it with a mesoncustom_targetrunning${compiler} -E.
Quoted 8 lines
Note: default bison on macOS is still too old (v2.3 vs v3.0) and a newer version needs to be installed via homebrew. I'll take a look at supporting v2.3.
Changes in v2:
* Don't remove the indent step but only run on linux hosts.
Thanks: this series is queued on the "hex-next-express" branch at https://github.com/quic/qemu/
Quoted 9 lines
Anton Johansson (2):
target/hexagon: Replacepreparescript with meson target target/hexagon: Only indent on linuxtarget/hexagon/idef-parser/prepare | 24 ------------------------ target/hexagon/meson.build | 5 +++-- 2 files changed, 3 insertions(+), 26 deletions(-)delete mode 100755 target/hexagon/idef-parser/prepare