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

Git build failure on Ubuntu 24.04 #1099

Closed
jtesta opened this issue Jun 26, 2024 · 4 comments · Fixed by #1100
Closed

Git build failure on Ubuntu 24.04 #1099

jtesta opened this issue Jun 26, 2024 · 4 comments · Fixed by #1100

Comments

@jtesta
Copy link

jtesta commented Jun 26, 2024

On a fresh and fully updated Ubuntu 24.04 VM, building and installing directly from git fails.

I installed the documented prerequisites with:

$ sudo apt install build-essential llvm clang libclang-dev cmake libssl-dev pkg-config python3 git
$ sudo apt install cargo llvm-dev

Then I ran:

$ cargo install --git https://github.com/immunant/c2rust.git c2rust
[...]
   Compiling c2rust v0.18.0 (/home/myuser/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/e526781/c2rust)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcwEWYny/symbols.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.00.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.01.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.02.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.03.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.04.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.05.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.06.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.07.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.08.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.c2rust_transpile.cfeb0086e1a78971-cgu.09.rcgu.o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199.4g1fcsc820e3uema.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/cargo-installb7pocu/release/deps" "-L" "/tmp/cargo-installb7pocu/release/build/c2rust-ast-exporter-f4cc18e23c346db0/out/build/lib" "-L" "/tmp/cargo-installb7pocu/release/build/c2rust-ast-exporter-f4cc18e23c346db0/out/build" "-L" "/usr/lib/llvm-18/lib" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installb7pocu/release/deps/libc2rust_transpile-2d9c6003b93ab561.rlib" "/tmp/cargo-installb7pocu/release/deps/libserde_bencode-35547d66b40fca66.rlib" "/tmp/cargo-installb7pocu/release/deps/liblog_reroute-f0bacdb226972376.rlib" "/tmp/cargo-installb7pocu/release/deps/libarc_swap-adc408d3ef3cfc93.rlib" "/tmp/cargo-installb7pocu/release/deps/libstrum-e43bbd2d98727921.rlib" "/tmp/cargo-installb7pocu/release/deps/libdtoa-419a0f6496949c6f.rlib" "/tmp/cargo-installb7pocu/release/deps/libsmallvec-bdafd60f8d1659ee.rlib" "/tmp/cargo-installb7pocu/release/deps/libitertools-37abd367e3339b4a.rlib" "/tmp/cargo-installb7pocu/release/deps/libeither-5c770101b834f2e6.rlib" "/tmp/cargo-installb7pocu/release/deps/libc2rust_ast_builder-8d71ed544e2baa30.rlib" "/tmp/cargo-installb7pocu/release/deps/libc2rust_ast_printer-ebb275749dccd210.rlib" "/tmp/cargo-installb7pocu/release/deps/libprettyplease-256bdf54e449267e.rlib" "/tmp/cargo-installb7pocu/release/deps/libsyn-70d5e64753adf755.rlib" "/tmp/cargo-installb7pocu/release/deps/libquote-245d77c6235689d8.rlib" "/tmp/cargo-installb7pocu/release/deps/libproc_macro2-8d12eaa75c9dec62.rlib" "/tmp/cargo-installb7pocu/release/deps/libunicode_ident-6d4ad0ce6229e687.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-b4653c0442afc79d.rlib" "/tmp/cargo-installb7pocu/release/deps/libpathdiff-ac6ddf25c6b6ca5c.rlib" "/tmp/cargo-installb7pocu/release/deps/libhandlebars-55a4b6a473a84670.rlib" "/tmp/cargo-installb7pocu/release/deps/libpest-e13cbdd6a5eda77d.rlib" "/tmp/cargo-installb7pocu/release/deps/libucd_trie-6643386c055681b5.rlib" "/tmp/cargo-installb7pocu/release/deps/libthiserror-d3f0fc8148e74878.rlib" "/tmp/cargo-installb7pocu/release/deps/libserde_json-b6a513ccc0ebe3c5.rlib" "/tmp/cargo-installb7pocu/release/deps/libitoa-96a05def571e3048.rlib" "/tmp/cargo-installb7pocu/release/deps/libryu-0c2cbf2f29c4f470.rlib" "/tmp/cargo-installb7pocu/release/deps/libc2rust_ast_exporter-ee9a98f6adda47fd.rlib" "/tmp/cargo-installb7pocu/release/deps/libserde_bytes-58b9c4fc049a3af0.rlib" "/tmp/cargo-installb7pocu/release/deps/libserde_cbor-269116a5b1c0c035.rlib" "/tmp/cargo-installb7pocu/release/deps/libhalf-97e21f8fef43d591.rlib" "/tmp/cargo-installb7pocu/release/deps/libfern-052b9a2d64483d96.rlib" "/tmp/cargo-installb7pocu/release/deps/libcolored-20fc290ebb461778.rlib" "/tmp/cargo-installb7pocu/release/deps/libis_terminal-0e69f53bda849293.rlib" "/tmp/cargo-installb7pocu/release/deps/libfailure-30629c4b70adf1f8.rlib" "/tmp/cargo-installb7pocu/release/deps/libbacktrace-9d4406f276738b8a.rlib" "/tmp/cargo-installb7pocu/release/deps/libminiz_oxide-0288315c7bdcccfc.rlib" "/tmp/cargo-installb7pocu/release/deps/libadler-58d7465abc116884.rlib" "/tmp/cargo-installb7pocu/release/deps/libobject-f9e2282c3de252d8.rlib" "/tmp/cargo-installb7pocu/release/deps/libaddr2line-3ea6a33d4f682889.rlib" "/tmp/cargo-installb7pocu/release/deps/libgimli-bf3111e8d1a9c5b0.rlib" "/tmp/cargo-installb7pocu/release/deps/libcfg_if-990fb7313fdf7f92.rlib" "/tmp/cargo-installb7pocu/release/deps/librustc_demangle-a80d07810901cafc.rlib" "/tmp/cargo-installb7pocu/release/deps/libcolored-8b4bab611c508d2a.rlib" "/tmp/cargo-installb7pocu/release/deps/liblazy_static-baeb24292c2687fe.rlib" "/tmp/cargo-installb7pocu/release/deps/libregex-410c7fb95aaa541f.rlib" "/tmp/cargo-installb7pocu/release/deps/libregex_automata-d0f7e0b9e320102e.rlib" "/tmp/cargo-installb7pocu/release/deps/libaho_corasick-4ffc4155407fa4aa.rlib" "/tmp/cargo-installb7pocu/release/deps/libmemchr-65bae949b6a94c23.rlib" "/tmp/cargo-installb7pocu/release/deps/libregex_syntax-0919eca57dc20a52.rlib" "/tmp/cargo-installb7pocu/release/deps/liblog-7b11cf43913b3294.rlib" "/tmp/cargo-installb7pocu/release/deps/libclap-fef939aaa0e2032a.rlib" "/tmp/cargo-installb7pocu/release/deps/libatty-a360cdfcfca144fa.rlib" "/tmp/cargo-installb7pocu/release/deps/liblibc-11ef4d3be82f4578.rlib" "/tmp/cargo-installb7pocu/release/deps/libstrsim-5e9c22711e450baa.rlib" "/tmp/cargo-installb7pocu/release/deps/libtermcolor-7fe42030e6a13b53.rlib" "/tmp/cargo-installb7pocu/release/deps/libtextwrap-8d9aba813ce53de1.rlib" "/tmp/cargo-installb7pocu/release/deps/libclap_lex-550b22b80f02a94e.rlib" "/tmp/cargo-installb7pocu/release/deps/libos_str_bytes-3962ccd340c22d91.rlib" "/tmp/cargo-installb7pocu/release/deps/libindexmap-35d5b3f080d18792.rlib" "/tmp/cargo-installb7pocu/release/deps/libhashbrown-2ba232e166fb8274.rlib" "/tmp/cargo-installb7pocu/release/deps/libserde-ee88506c3b099820.rlib" "/tmp/cargo-installb7pocu/release/deps/libbitflags-3992ac9bab25daad.rlib" "/tmp/cargo-installb7pocu/release/deps/libonce_cell-f74ad9ad610e6cc8.rlib" "/tmp/cargo-installb7pocu/release/deps/libyaml_rust-85aa2385e78c38d7.rlib" "/tmp/cargo-installb7pocu/release/deps/liblinked_hash_map-d16dff8d30a0da17.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-74aa92219e1a8d2b.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-556ff44c866a894d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-61d4cbd91c8be0e8.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-c235ac718876a7bc.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-724ae4ee6ef0156e.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-099fa4b14e882175.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-9126b5789c3b641d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-a92d56cfb42519d5.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-2b018f940072398c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-39700fa65937180a.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-a8703df15a583722.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-1d154e48fff50a00.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-696e7611411ecc8d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-04375ac4e710b803.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e691f0468a1ac82b.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-78e98507e9d056e5.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-599bfec9aeefee4c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-393698f6b78844c3.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-81a4af3d0626b705.rlib" "-Wl,-Bdynamic" "-lclangTooling" "-lclangFrontend" "-lclangASTMatchers" "-lclangParse" "-lclangSerialization" "-lclangSema" "-lclangSupport" "-lclangAPINotes" "-lclangEdit" "-lclangAnalysis" "-lclangDriver" "-lclangFormat" "-lclangToolingCore" "-lclangAST" "-lclangRewrite" "-lclangLex" "-lclangBasic" "-lLLVM-18" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/cargo-installb7pocu/release/deps/c2rust_transpile-dbcfde49c8be6199" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: /usr/bin/ld: /usr/lib/llvm-18/lib/libclangAnalysis.a(UnsafeBufferUsage.cpp.o): in function `clang::ast_matchers::internal::matcher_ignoringImpCasts0Matcher::matches(clang::Expr const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const':
          (.text._ZNK5clang12ast_matchers8internal32matcher_ignoringImpCasts0Matcher7matchesERKNS_4ExprEPNS1_14ASTMatchFinderEPNS1_21BoundNodesTreeBuilderE[_ZNK5clang12ast_matchers8internal32matcher_ignoringImpCasts0Matcher7matchesERKNS_4ExprEPNS1_14ASTMatchFinderEPNS1_21BoundNodesTreeBuilderE]+0x55): undefined reference to `clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const'
          /usr/bin/ld: /usr/lib/llvm-18/lib/libclangAnalysis.a(UnsafeBufferUsage.cpp.o): in function `clang::ast_matchers::internal::matcher_ignoringParenImpCasts0Matcher::matches(clang::Expr const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const':
[...]

I've attached the full output of the above command, as it is too long to include inline:
ubuntu24_git_build_failure_output.txt

@jtesta
Copy link
Author

jtesta commented Jun 26, 2024

FYI, I dusted off an old Ubuntu 20.04 VM, and managed to successfully install c2rust with the above instructions.

@thedataking
Copy link
Contributor

Thanks for the detailed report. This kind of breakage happens after new versions of clang are released since we rely on internals of the clang AST. I don't have access to a ubuntu 24.04 box right now but I bet if you try with an older version, it will build correctly on 24.04. That is not to say that we don't need to fix this issue; we definitely should.

thedataking added a commit that referenced this issue Jun 27, 2024
clangAnalysis depends on clangASTMatchers and thus needs to come
before it. Fixes #1099.
@thedataking
Copy link
Contributor

@jtesta can you try PR #1100 and let me know if it fixes the issue for you?

@jtesta
Copy link
Author

jtesta commented Jun 27, 2024

Yep, that works!:

$ git clone https://github.com/immunant/c2rust.git
$ git fetch origin pull/1100/head:pr1100
$ git checkout pr1100
$ cargo install --git file:///home/user/c2rust c2rust
[...]
   Compiling c2rust v0.18.0 (/home/user/.cargo/git/checkouts/c2rust-c49f1e3fd59cf9fe/d81b148/c2rust)
    Finished release [optimized] target(s) in 4m 14s
  Installing /home/user/.cargo/bin/c2rust
  Installing /home/user/.cargo/bin/c2rust-transpile
   Installed package `c2rust v0.18.0 (file:///home/user/c2rust#d81b1483)` (executables `c2rust`, `c2rust-transpile`)
warning: be sure to add `/home/user/.cargo/bin` to your PATH to be able to run the installed binaries

Thanks for the quick fix!

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.

2 participants