Link dynamically against libclang diff --color -rupN a/c2rust/Cargo.toml b/c2rust/Cargo.toml --- a/c2rust/Cargo.toml 2025-02-24 14:19:52.000000000 +0100 +++ b/c2rust/Cargo.toml 2025-03-14 09:17:13.865581468 +0100 @@ -28,7 +28,3 @@ c2rust-transpile = { version = "0.20.0", [build-dependencies] c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.20.0" } - -[features] -# Force static linking of LLVM -llvm-static = ["c2rust-transpile/llvm-static"] diff --color -rupN a/c2rust-ast-exporter/Cargo.toml b/c2rust-ast-exporter/Cargo.toml --- a/c2rust-ast-exporter/Cargo.toml 2025-02-24 14:19:52.000000000 +0100 +++ b/c2rust-ast-exporter/Cargo.toml 2025-03-14 09:17:44.335314550 +0100 @@ -27,5 +27,3 @@ c2rust-build-paths = { path = "../c2rust [features] default = [] -# Force static linking of LLVM -llvm-static = [] diff --color -rupN a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs --- a/c2rust-ast-exporter/build.rs 2025-02-24 14:19:52.000000000 +0100 +++ b/c2rust-ast-exporter/build.rs 2025-03-14 09:20:37.350465585 +0100 @@ -155,63 +155,7 @@ fn build_native(llvm_info: &LLVMInfo) { println!("cargo:rustc-link-search=native={}", llvm_lib_dir); - // Some distro's, including arch and Fedora, no longer build with - // BUILD_SHARED_LIBS=ON; programs linking to clang are required to - // link to libclang-cpp.so instead of individual libraries. - let use_libclang = if cfg!(target_os = "macos") { - // We hit an issue linking against the shared libraries for the homebrew - // version of LLVM 15 because they use a feature (opaque pointers) which - // are not understood by earlier versions of LLVM so we link against - // libclang unless static linking has been explicitly requested. - !cfg!(feature = "llvm-static") - } else { - // target_os = "linux" - let mut libclang_path = PathBuf::new(); - libclang_path.push(llvm_lib_dir); - libclang_path.push("libclang-cpp.so"); - libclang_path.exists() - }; - - if use_libclang { - println!("cargo:rustc-link-lib=clang-cpp"); - } else { - // Link against these Clang libs. The ordering here is important! Libraries - // must be listed before their dependencies when statically linking. - let mut clang_libs = vec![ - "clangTooling", - "clangFrontend", - "clangParse", - "clangSema", - "clangAnalysis", - "clangASTMatchers", - "clangSerialization", - "clangEdit", - "clangDriver", - "clangFormat", - "clangToolingCore", - "clangAST", - "clangRewrite", - "clangLex", - "clangBasic", - ]; - if llvm_info.llvm_major_version >= 15 { - // insert after clangSema - let sema_pos = clang_libs.iter().position(|&r| r == "clangSema").unwrap(); - clang_libs.insert(sema_pos + 1, "clangSupport"); - } - if llvm_info.llvm_major_version >= 18 { - // insert after clangSupport - let sema_pos = clang_libs - .iter() - .position(|&r| r == "clangSupport") - .unwrap(); - clang_libs.insert(sema_pos + 1, "clangAPINotes"); - } - - for lib in &clang_libs { - println!("cargo:rustc-link-lib={}", lib); - } - } + println!("cargo:rustc-link-lib=clang-cpp"); for lib in &llvm_info.libs { // IMPORTANT: We cannot specify static= or dylib= here because rustc diff --color -rupN a/c2rust-ast-exporter/src/CMakeLists.txt b/c2rust-ast-exporter/src/CMakeLists.txt --- a/c2rust-ast-exporter/src/CMakeLists.txt 2025-02-24 14:19:52.000000000 +0100 +++ b/c2rust-ast-exporter/src/CMakeLists.txt 2025-03-14 09:16:06.622837188 +0100 @@ -95,11 +95,7 @@ set_target_properties(c2rust-ast-exporte # PRIVATE was added to make c2rust-ast-exporter build with LLVM 6.0. Keyword # description: https://cmake.org/pipermail/cmake/2016-May/063400.html target_link_libraries(c2rust-ast-exporter PRIVATE - clangAST - clangFrontend - clangTooling - clangBasic - clangASTMatchers + clang-cpp tinycbor ) diff --color -rupN a/c2rust-transpile/Cargo.toml b/c2rust-transpile/Cargo.toml --- a/c2rust-transpile/Cargo.toml 2025-02-24 14:19:52.000000000 +0100 +++ b/c2rust-transpile/Cargo.toml 2025-03-14 09:16:06.626170493 +0100 @@ -38,7 +38,3 @@ smallvec = "1.0" strum = "0.24" strum_macros = "0.24" syn = { version = "1.0", features = ["full", "extra-traits", "parsing", "printing"]} - -[features] -# Force static linking of LLVM -llvm-static = ["c2rust-ast-exporter/llvm-static"]