-flto=thin breaks .func asm check on macOS
Invoking meson (tested both versions 0.63.3 and 1.0.1) as CFLAGS="-flto=thin" meson setup build
:
$ ninja -Cbuild
ninja: Entering directory `build'
[53/121] Compiling C object src/libdav1d.6.dylib.p/arm_64_refmvs.S.o
FAILED: src/libdav1d.6.dylib.p/arm_64_refmvs.S.o
cc -Isrc/libdav1d.6.dylib.p -Isrc -I../src -I. -I.. -Iinclude/dav1d -I../include/dav1d -Iinclude -I../include -fcolor-diagnostics -DNDEBUG -Wall -Winvalid-pch -Wextra -std=c99 -O3 -fvisibility=hidden -Wundef -Werror=vla -Wno-missing-field-initializers -Wno-unused-parameter -Wstrict-prototypes -Werror=missing-prototypes -Wshorten-64-to-32 -fomit-frame-pointer -ffast-math -flto=thin -Werror -MD -MQ src/libdav1d.6.dylib.p/arm_64_refmvs.S.o -MF src/libdav1d.6.dylib.p/arm_64_refmvs.S.o.d -o src/libdav1d.6.dylib.p/arm_64_refmvs.S.o -c ../src/arm/64/refmvs.S
<instantiation>:21:9: error: unknown directive
.func _dav1d_splat_mv_neon
^
../src/arm/64/refmvs.S:34:1: note: while in macro instantiation
function splat_mv_neon, export=1
^
<instantiation>:5:9: error: unknown directive
.endfunc
^
../src/arm/64/refmvs.S:91:1: note: while in macro instantiation
endfunc
^
[54/121] Compiling C object src/libdav1d.6.dylib.p/arm_64_looprestoration_common.S.o
... snip ...
Relevant part of the log:
Running compile:
Working directory: /Users/user/Desktop/dav1d/build/meson-private/tmp2up1aal6
Command line: cc /Users/user/Desktop/dav1d/build/meson-private/tmp2up1aal6/testfile.c -o /Users/user/Desktop/dav1d/build/meson-private/tmp2up1aal6/output.obj -c -flto=thin -Werror -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=c99.
Code:
__asm__ (
".func meson_test"
".endfunc"
);
Compiler stdout:
.
Compiler stderr:
error: unknown directive
.func meson_test.endfunc
^
error: unknown directive
.func meson_test.endfunc
^
meson.build:350: WARNING: Project targets '>= 0.49.0' but uses feature introduced in '0.58.0': format strings.
Message: HAVE_AS_FUNC: True
Using this to debug the value easily:
diff --git a/meson.build b/meson.build
index bab3188..1152464 100644
--- a/meson.build
+++ b/meson.build
@@ -347,6 +347,7 @@ if (is_asm_enabled and
);
'''
have_as_func = cc.compiles(as_func_code)
+ message(f'HAVE_AS_FUNC: @have_as_func@')
cdata.set10('HAVE_AS_FUNC', have_as_func)
# fedora package build infrastructure uses a gcc specs file to enable
A standalone test for .func
:
$ cat t.c
int main(void)
{
__asm__ (
".func meson_test"
".endfunc"
);
return 0;
}
$ cc t.c -o t.o -flto=thin -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=c99
error: <inline asm>:1:2: unknown directive
.func meson_test.endfunc
^
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ echo $?
1