Message ID | 20220110131001.614319-2-f4bug@amsat.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | host: Support macOS 12 | expand |
On Mon, Jan 10, 2022 at 02:09:55PM +0100, Philippe Mathieu-Daudé wrote: > We can pass C/CPP/LD flags via CFLAGS/CXXFLAGS/LDFLAGS environment > variables, or via configure --extra-cflags / --extra-cxxflags / > --extra-ldflags options. Provide similar behavior for Objective C: > use existing flags from $OBJCFLAGS, or passed via --extra-objcflags. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > configure | 8 ++++++++ > meson.build | 5 +++++ > 2 files changed, 13 insertions(+) > > diff --git a/configure b/configure > index 0c57a063c66..adb42d8beb1 100755 > --- a/configure > +++ b/configure > @@ -288,6 +288,7 @@ done > > EXTRA_CFLAGS="" > EXTRA_CXXFLAGS="" > +EXTRA_OBJCFLAGS="" > EXTRA_LDFLAGS="" > > xen_ctrl_version="$default_feature" > @@ -400,9 +401,12 @@ for opt do > --extra-cflags=*) > EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" > EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" > + EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" > ;; > --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" > ;; > + --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" > + ;; > --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" > ;; > --enable-debug-info) debug_info="yes" > @@ -781,6 +785,8 @@ for opt do > ;; > --extra-cxxflags=*) > ;; > + --extra-objcflags=*) > + ;; > --extra-ldflags=*) > ;; > --enable-debug-info) > @@ -1318,6 +1324,7 @@ Advanced options (experts only): > --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] > --extra-cflags=CFLAGS append extra C compiler flags CFLAGS > --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS > + --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS > --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS > --cross-cc-ARCH=CC use compiler when building ARCH guest test cases > --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests > @@ -3843,6 +3850,7 @@ if test "$skip_meson" = no; then > echo "[built-in options]" >> $cross > echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross > echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross > + test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross > echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross > echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross > echo "[binaries]" >> $cross > diff --git a/meson.build b/meson.build > index 0e52f54b100..a21305d62c1 100644 > --- a/meson.build > +++ b/meson.build > @@ -3286,6 +3286,11 @@ > + ['-O' + get_option('optimization')] > + (get_option('debug') ? ['-g'] : []))} > endif > +if targetos == 'darwin' > + summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') > + + ['-O' + get_option('optimization')] > + + (get_option('debug') ? ['-g'] : []))} Hi Philippe, You need to add something like below to actually use the flags in build: add_global_arguments(config_host['QEMU_OBJCFLAGS'].split(), native: false, language: 'objc') Regards, Roman > +endif > link_args = get_option(link_language + '_link_args') > if link_args.length() > 0 > summary_info += {'LDFLAGS': ' '.join(link_args)} > -- > 2.33.1
+Paolo who I forgot to Cc. On 1/11/22 18:16, Roman Bolshakov wrote: > On Mon, Jan 10, 2022 at 02:09:55PM +0100, Philippe Mathieu-Daudé wrote: >> We can pass C/CPP/LD flags via CFLAGS/CXXFLAGS/LDFLAGS environment >> variables, or via configure --extra-cflags / --extra-cxxflags / >> --extra-ldflags options. Provide similar behavior for Objective C: >> use existing flags from $OBJCFLAGS, or passed via --extra-objcflags. >> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> --- >> configure | 8 ++++++++ >> meson.build | 5 +++++ >> 2 files changed, 13 insertions(+) >> >> diff --git a/configure b/configure >> index 0c57a063c66..adb42d8beb1 100755 >> --- a/configure >> +++ b/configure >> @@ -288,6 +288,7 @@ done >> >> EXTRA_CFLAGS="" >> EXTRA_CXXFLAGS="" >> +EXTRA_OBJCFLAGS="" >> EXTRA_LDFLAGS="" >> >> xen_ctrl_version="$default_feature" >> @@ -400,9 +401,12 @@ for opt do >> --extra-cflags=*) >> EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" >> EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" >> + EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" >> ;; >> --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" >> ;; >> + --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" >> + ;; >> --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" >> ;; >> --enable-debug-info) debug_info="yes" >> @@ -781,6 +785,8 @@ for opt do >> ;; >> --extra-cxxflags=*) >> ;; >> + --extra-objcflags=*) >> + ;; >> --extra-ldflags=*) >> ;; >> --enable-debug-info) >> @@ -1318,6 +1324,7 @@ Advanced options (experts only): >> --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] >> --extra-cflags=CFLAGS append extra C compiler flags CFLAGS >> --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS >> + --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS >> --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS >> --cross-cc-ARCH=CC use compiler when building ARCH guest test cases >> --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests >> @@ -3843,6 +3850,7 @@ if test "$skip_meson" = no; then >> echo "[built-in options]" >> $cross >> echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross >> echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross >> + test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross >> echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross >> echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross >> echo "[binaries]" >> $cross >> diff --git a/meson.build b/meson.build >> index 0e52f54b100..a21305d62c1 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -3286,6 +3286,11 @@ >> + ['-O' + get_option('optimization')] >> + (get_option('debug') ? ['-g'] : []))} >> endif >> +if targetos == 'darwin' >> + summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') >> + + ['-O' + get_option('optimization')] >> + + (get_option('debug') ? ['-g'] : []))} > > Hi Philippe, > > You need to add something like below to actually use the flags in build: > > add_global_arguments(config_host['QEMU_OBJCFLAGS'].split(), > native: false, language: 'objc') But so far we don't need any particular QEMU_OBJCFLAGS, so I rather not add unused code. This patch simply adds passing ObjC flags from "./configure --extra-objcflags=". Anyway, with your/Akihiko/Christian help during review, this flag is not necessary anymore to build softmmu/tools (I still have to figure how to silent the "#pragma FENV_ACCESS" warning in tests), so let forget about this patch (except if we expect macOS ObjC to keep evolving and need a way to pass OBJCFLAGS).
+Emilio On 1/12/22 14:46, Philippe Mathieu-Daudé wrote: > Anyway, with your/Akihiko/Christian help during review, this flag > is not necessary anymore to build softmmu/tools (I still have to > figure how to silent the "#pragma FENV_ACCESS" warning in tests), > so let forget about this patch (except if we expect macOS ObjC to > keep evolving and need a way to pass OBJCFLAGS). Apparently Clang equivalent of "#pragma STDC FENV_ACESS ON" is "-ffp-model=strict" https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffp-model I'll see if patching tests/fp/meson.build is sufficient.
On 1/12/22 15:09, Philippe Mathieu-Daudé wrote: > +Emilio > > On 1/12/22 14:46, Philippe Mathieu-Daudé wrote: >> Anyway, with your/Akihiko/Christian help during review, this flag >> is not necessary anymore to build softmmu/tools (I still have to >> figure how to silent the "#pragma FENV_ACCESS" warning in tests), >> so let forget about this patch (except if we expect macOS ObjC to >> keep evolving and need a way to pass OBJCFLAGS). > > Apparently Clang equivalent of "#pragma STDC FENV_ACESS ON" is > "-ffp-model=strict" > > https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffp-model > > I'll see if patching tests/fp/meson.build is sufficient. This seems to do the job: -- >8 -- diff --git a/tests/fp/meson.build b/tests/fp/meson.build index 59776a00a79..b790487648a 100644 --- a/tests/fp/meson.build +++ b/tests/fp/meson.build @@ -37,6 +37,12 @@ '-Wno-error', ] +if cc.get_id() == 'clang' and cc.has_argument('-ffp-model=strict') + # Clang does not support '#pragma STDC FENV_ACCESS', but starting + # with Clang 10.0 the equivalent is -ffp-model=strict. + tfcflags += [ '-ffp-model=strict' ] +endif + tfgencases = [ tfdir / 'genCases_ui32.c', tfdir / 'genCases_ui64.c', ---
diff --git a/configure b/configure index 0c57a063c66..adb42d8beb1 100755 --- a/configure +++ b/configure @@ -288,6 +288,7 @@ done EXTRA_CFLAGS="" EXTRA_CXXFLAGS="" +EXTRA_OBJCFLAGS="" EXTRA_LDFLAGS="" xen_ctrl_version="$default_feature" @@ -400,9 +401,12 @@ for opt do --extra-cflags=*) EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" + EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" ;; --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" ;; + --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" + ;; --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" ;; --enable-debug-info) debug_info="yes" @@ -781,6 +785,8 @@ for opt do ;; --extra-cxxflags=*) ;; + --extra-objcflags=*) + ;; --extra-ldflags=*) ;; --enable-debug-info) @@ -1318,6 +1324,7 @@ Advanced options (experts only): --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] --extra-cflags=CFLAGS append extra C compiler flags CFLAGS --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS + --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS --cross-cc-ARCH=CC use compiler when building ARCH guest test cases --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests @@ -3843,6 +3850,7 @@ if test "$skip_meson" = no; then echo "[built-in options]" >> $cross echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross + test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross echo "[binaries]" >> $cross diff --git a/meson.build b/meson.build index 0e52f54b100..a21305d62c1 100644 --- a/meson.build +++ b/meson.build @@ -3286,6 +3286,11 @@ + ['-O' + get_option('optimization')] + (get_option('debug') ? ['-g'] : []))} endif +if targetos == 'darwin' + summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + + ['-O' + get_option('optimization')] + + (get_option('debug') ? ['-g'] : []))} +endif link_args = get_option(link_language + '_link_args') if link_args.length() > 0 summary_info += {'LDFLAGS': ' '.join(link_args)}
We can pass C/CPP/LD flags via CFLAGS/CXXFLAGS/LDFLAGS environment variables, or via configure --extra-cflags / --extra-cxxflags / --extra-ldflags options. Provide similar behavior for Objective C: use existing flags from $OBJCFLAGS, or passed via --extra-objcflags. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- configure | 8 ++++++++ meson.build | 5 +++++ 2 files changed, 13 insertions(+)