Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust/12 bindgen fails on aarch64 #13417

Closed
alyssais opened this issue Jul 12, 2024 · 4 comments · Fixed by #13421
Closed

rust/12 bindgen fails on aarch64 #13417

alyssais opened this issue Jul 12, 2024 · 4 comments · Fixed by #13421

Comments

@alyssais
Copy link
Contributor

Describe the bug

This test adds -mtls-dialect=gnu2 to the C compiler arguments. This is fine on x86_64, but not on aarch64, where that option doesn't exist:

Failed during: build
Reason: Compiling source code failed.
 

(inprocess) $ setup --prefix /usr --libdir lib 'test cases/rust/12 bindgen' '/meson/b 4c9eb471e8' --backend=ninja
The Meson build system
Version: 1.5.0.rc2
Source dir: /meson/test cases/rust/12 bindgen
Build dir: /meson/b 4c9eb471e8
Build type: native build
Project name: rustmod bindgen
Project version: undefined
C compiler for the host machine: cc (gcc 14.1.1 "cc (GCC) 14.1.1 20240701 (Red Hat 14.1.1-7)")
C linker for the host machine: cc ld.bfd 2.41-37
C++ compiler for the host machine: c++ (gcc 14.1.1 "c++ (GCC) 14.1.1 20240701 (Red Hat 14.1.1-7)")
C++ linker for the host machine: c++ ld.bfd 2.41-37
Rust compiler for the host machine: rustc -C linker=cc (rustc 1.79.0)
Rust linker for the host machine: rustc -C linker=cc ld.bfd 2.41-37
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program bindgen found: YES (/usr/bin/bindgen)
test cases/rust/12 bindgen/meson.build:39: WARNING: Project targets '>= 0.63' but uses feature introduced in '1.4.0': bindgen_version arg in rust.bindgen.
Program bindgen found: NO found 0.69.4 but need: '< 0.1', '> 10000' (/usr/bin/bindgen)
test cases/rust/12 bindgen/meson.build:47: WARNING: Project targets '>= 0.63' but uses feature introduced in '1.0.0': "rust.bindgen" keyword argument "include_directories" of type array[str].
Program bindgen found: YES (/usr/bin/bindgen)
Program src/gen_header.py found: YES (/usr/bin/python3 /meson/test cases/rust/12 bindgen/src/gen_header.py)
Program src/gen_header.py found: YES (/usr/bin/python3 /meson/test cases/rust/12 bindgen/src/gen_header.py)
test cases/rust/12 bindgen/meson.build:104: WARNING: Project targets '>= 0.63' but uses feature introduced in '1.4.0': output_inline_wrapper arg in rust.bindgen.
Found pkg-config: YES (/usr/bin/pkg-config) 2.1.1
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency zlib found: NO (tried pkgconfig, cmake and system)
test cases/rust/12 bindgen/dependencies/meson.build:27: WARNING: Project targets '>= 0.63' but uses feature introduced in '1.0.0': dependencies arg in rust.bindgen.
Build targets in project: 23
WARNING: Project specifies a minimum meson_version '>= 0.63' but uses features which were added in newer versions:
 * 1.0.0: {'"rust.bindgen" keyword argument "include_directories" of type array[str]', 'dependencies arg in rust.bindgen'}
 * 1.4.0: {'bindgen_version arg in rust.bindgen', 'output_inline_wrapper arg in rust.bindgen'}
NOTICE: Future-deprecated features used:
 * 1.0.0: {'module rust has been stabilized'}

rustmod bindgen undefined

  User defined options
    backend: ninja
    libdir : lib
    prefix : /usr

Found ninja-1.12.1 at /usr/bin/ninja
ninja explain: deps for 'rust_bin' are missing
ninja explain: deps for 'libclib.a.p/src_source.c.o' are missing
ninja explain: libclib.a.p/src_source.c.o is dirty
ninja explain: libclib.a is dirty
ninja explain: deps for 'header.rs' are missing
ninja explain: rust_bin is dirty
ninja explain: deps for 'rust_bin2' are missing
ninja explain: libclib.a is dirty
ninja explain: deps for 'gen.rs' are missing
ninja explain: output gen.h doesn't exist
ninja explain: gen.h is dirty
ninja explain: output other.h doesn't exist
ninja explain: other.h is dirty
ninja explain: rust_bin2 is dirty
ninja explain: deps for 'rust_bin3' are missing
ninja explain: deps for 'libc_wrapper.a.p/meson-generated_.._header3.c.o' are missing
ninja explain: deps for 'header3.rs' are missing
ninja explain: header3.c is dirty
ninja explain: libc_wrapper.a.p/meson-generated_.._header3.c.o is dirty
ninja explain: libc_wrapper.a is dirty
ninja explain: libclib.a is dirty
ninja explain: rust_bin3 is dirty
ninja explain: deps for 'sub/rust_bin3' are missing
ninja explain: libclib.a is dirty
ninja explain: deps for 'sub/gen.rs' are missing
ninja explain: gen.h is dirty
ninja explain: other.h is dirty
ninja explain: sub/rust_bin3 is dirty
ninja explain: deps for 'sub/rust_bin_subdir' are missing
ninja explain: libclib.a is dirty
ninja explain: deps for 'sub/header.rs' are missing
ninja explain: sub/rust_bin_subdir is dirty
ninja explain: deps for 'dependencies/rust_bin_int_dep' are missing
ninja explain: output dependencies/rust_bin_int_dep.p/structured/internal_main.rs doesn't exist
ninja explain: dependencies/rust_bin_int_dep.p/structured/internal_main.rs is dirty
ninja explain: deps for 'dependencies/libclib2.a.p/clib2.c.o' are missing
ninja explain: dependencies/libclib2.a.p/clib2.c.o is dirty
ninja explain: dependencies/libclib2.a is dirty
ninja explain: libclib.a is dirty
ninja explain: deps for 'dependencies/internal_dep.rs' are missing
ninja explain: gen.h is dirty
ninja explain: other.h is dirty
ninja explain: dependencies/internal_dep.rs is dirty
ninja explain: dependencies/rust_bin_int_dep is dirty
ninja explain: deps for 'gp_exe' are missing
ninja explain: output gp_exe.p/structured/global.rs doesn't exist
ninja explain: gp_exe.p/structured/global.rs is dirty
ninja explain: deps for 'libgp_lib.a.p/src_global.c.o' are missing
ninja explain: libgp_lib.a.p/src_global.c.o is dirty
ninja explain: libgp_lib.a is dirty
ninja explain: deps for 'global-project.rs' are missing
ninja explain: global-project.rs is dirty
ninja explain: gp_exe is dirty
ninja explain: deps for 'cpp_exe' are missing
ninja explain: output cpp_exe.p/structured/cpp.rs doesn't exist
ninja explain: cpp_exe.p/structured/cpp.rs is dirty
ninja explain: deps for 'libcpplib.a.p/src_impl.cpp.o' are missing
ninja explain: libcpplib.a.p/src_impl.cpp.o is dirty
ninja explain: libcpplib.a is dirty
ninja explain: deps for 'generated-cpp.rs' are missing
ninja explain: generated-cpp.rs is dirty
ninja explain: cpp_exe is dirty
ninja explain: meson-test-prereq is dirty
ninja explain: output meson-benchmark-prereq of phony edge with no inputs doesn't exist
ninja explain: meson-benchmark-prereq is dirty
ninja explain: libclib.a is dirty
ninja explain: rust_bin is dirty
ninja explain: rust_bin2 is dirty
ninja explain: libc_wrapper.a is dirty
ninja explain: rust_bin3 is dirty
ninja explain: sub/rust_bin3 is dirty
ninja explain: sub/rust_bin_subdir is dirty
ninja explain: dependencies/libclib2.a is dirty
ninja explain: dependencies/rust_bin_int_dep is dirty
ninja explain: libgp_lib.a is dirty
ninja explain: gp_exe is dirty
ninja explain: libcpplib.a is dirty
ninja explain: cpp_exe is dirty
[1/34] Generating gen.h with a custom command
[2/34] Generating other.h with a custom command
[3/34] Compiling C object libclib.a.p/src_source.c.o
FAILED: libclib.a.p/src_source.c.o 
cc -Ilibclib.a.p -I. '-I../test cases/rust/12 bindgen' '-I../test cases/rust/12 bindgen/include' -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -DPROJECT_ARG -mtls-dialect=gnu2 -DGLOBAL_ARG -mtls-dialect=gnu2 -DCMD_ARG -fPIC -MD -MQ libclib.a.p/src_source.c.o -MF libclib.a.p/src_source.c.o.d -o libclib.a.p/src_source.c.o -c '../test cases/rust/12 bindgen/src/source.c'
cc: error: unrecognized argument in option ‘-mtls-dialect=gnu2’
cc: note: valid arguments to ‘-mtls-dialect=’ are: desc trad
cc: error: unrecognized argument in option ‘-mtls-dialect=gnu2’
cc: note: valid arguments to ‘-mtls-dialect=’ are: desc trad
[4/34] Compiling C object libgp_lib.a.p/src_global.c.o
FAILED: libgp_lib.a.p/src_global.c.o 
cc -Ilibgp_lib.a.p -I. '-I../test cases/rust/12 bindgen' -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -DPROJECT_ARG -mtls-dialect=gnu2 -DGLOBAL_ARG -mtls-dialect=gnu2 -DCMD_ARG -fPIC -MD -MQ libgp_lib.a.p/src_global.c.o -MF libgp_lib.a.p/src_global.c.o.d -o libgp_lib.a.p/src_global.c.o -c '../test cases/rust/12 bindgen/src/global.c'
cc: error: unrecognized argument in option ‘-mtls-dialect=gnu2’
cc: note: valid arguments to ‘-mtls-dialect=’ are: desc trad
cc: error: unrecognized argument in option ‘-mtls-dialect=gnu2’
cc: note: valid arguments to ‘-mtls-dialect=’ are: desc trad
[5/34] Compiling C++ object libcpplib.a.p/src_impl.cpp.o
[6/34] Generating bindings for Rust rustmod-bindgen-src_header3.h
Failed to run rustfmt: cannot find binary path (non-fatal, continuing)
[7/34] Generating bindings for Rust rustmod-bindgen-src_global-project.h
Failed to run rustfmt: cannot find binary path (non-fatal, continuing)
[8/34] Copying '/meson/test cases/rust/12 bindgen/dependencies/internal_main.rs' to dependencies/rust_bin_int_dep.p/structured/internal_main.rs
[9/34] Generating bindings for Rust rustmod-bindgen-src_header.hpp
clang diag: ../test cases/rust/12 bindgen/src/header.hpp:1:9: warning: #pragma once in main file [-Wpragma-once-outside-header]
Failed to run rustfmt: cannot find binary path (non-fatal, continuing)
[10/34] Generating bindings for Rust rustmod-bindgen-src_header.h
Failed to run rustfmt: cannot find binary path (non-fatal, continuing)
[11/34] Generating bindings for Rust sub/rustmod-bindgen-.._src_header.h
Failed to run rustfmt: cannot find binary path (non-fatal, continuing)
[12/34] Generating bindings for Rust dependencies/rustmod-bindgen-internal_dep.h
Failed to run rustfmt: cannot find binary path (non-fatal, continuing)
ninja: build stopped: subcommand failed.

cc @dcbaker

To Reproduce

In a fresh fedora container:

dnf install ninja-build gcc-c++ rustc bindgen-cli
python3 run_project_tests.py --only=rust

Expected behavior
Test passes.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) Fedora 40
  • what Python version are you using e.g. 3.8.0 3.12.2
  • what meson --version 0392722
  • what ninja --version if it's a Ninja build 1.12.1
@dcbaker
Copy link
Member

dcbaker commented Jul 12, 2024

Sigh, of course the tls-dialect options are different on aarch64 and x86_64... I really just need an argument that GCC takes that Clang doesn't.

@alyssais
Copy link
Contributor Author

Looking through the GCC manual, I can see a few options that shouldn't make much of a difference to the compilation, and are supported by GCC and not (my version of) Clang, e.g. -fstrict-flex-arrays or -fsplit-wide-types-early, but there's a big risk that any of these will end up implemented in Clang in the future and break the test again…

@dcbaker
Copy link
Member

dcbaker commented Jul 12, 2024

Yeah, I really wanted a -fgcc option, lol

@thesamesam
Copy link
Collaborator

Please try something like -fipa-pta. It's a random, kind of specific optimisation pass implementation detail which I can't see Clang ever implementing under that name, and Clang these days avoids adding new flags which are purely stubs just for GCC compat (i.e. they only implement things for real).

dcbaker added a commit to dcbaker/meson that referenced this issue Jul 12, 2024
-m arguments aren't portable across architectures. -fipa-pta will
hopefully be portable for gcc, but also not implemented by clang.

Fixes: mesonbuild#13417
dcbaker added a commit to dcbaker/meson that referenced this issue Jul 12, 2024
-m arguments aren't portable across architectures. -fipa-pta will
hopefully be portable for GCC, but also not implemented by clang.

Fixes: mesonbuild#13417
eli-schwartz pushed a commit that referenced this issue Jul 26, 2024
-m arguments aren't portable across architectures. -fipa-pta will
hopefully be portable for GCC, but also not implemented by clang.

Fixes: #13417
(cherry picked from commit 44323ff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants