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

Unable to open homebrew llvm's libclang shared library, missing symbol #1777

Closed
CamJN opened this issue May 6, 2020 · 16 comments
Closed

Unable to open homebrew llvm's libclang shared library, missing symbol #1777

CamJN opened this issue May 6, 2020 · 16 comments

Comments

@CamJN
Copy link

CamJN commented May 6, 2020

Problem description

I'm using bindgen 0.53.2 and I installed llvm from homebrew, and pointed bindgen at it with the following, which has worked for me in the past.

    let key = "LLVM_CONFIG_PATH";
    env::set_var(key, env::var(key).unwrap_or("/usr/local/opt/llvm/bin/llvm-config".to_string()));

However, when I try and run cargo build (I'm using bindgen in build.rs), bindgen panics and complains that it cannot find the __ZTIN4llvm23MCAsmParserSemaCallbackE symbol in /usr/local/opt/llvm@10/lib/libclang.dylib, and that symbol is expected because of /Users/camdennarzt/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib.

Input C Headers

I know that I'm not supposed to show a header with includes here, but I'm pretty sure that the header isn't the problem (I don't think bindgen gets that far).

/*
 * Copyright (c) 2006, 2007, 2010 Apple Inc. All rights reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this
 * file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPLE_LICENSE_HEADER_END@
 */
#ifndef _LIBPROC_H_
#define _LIBPROC_H_

#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/resource.h>
#include <stdint.h>
#include <stdbool.h>

#include <sys/proc_info.h>

#include <Availability.h>

/*
 * This header file contains private interfaces to obtain process information.
 * These interfaces are subject to change in future releases.
 */

/*!
 *       @define PROC_LISTPIDSPATH_PATH_IS_VOLUME
 *       @discussion This flag indicates that all processes that hold open
 *               file references on the volume associated with the specified
 *               path should be returned.
 */
#define PROC_LISTPIDSPATH_PATH_IS_VOLUME        1


/*!
 *       @define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY
 *       @discussion This flag indicates that file references that were opened
 *               with the O_EVTONLY flag should be excluded from the matching
 *               criteria.
 */
#define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY       2

__BEGIN_DECLS


/*!
 *       @function proc_listpidspath
 *       @discussion A function which will search through the current
 *               processes looking for open file references which match
 *               a specified path or volume.
 *       @param type types of processes to be searched (see proc_listpids)
 *       @param typeinfo adjunct information for type
 *       @param path file or volume path
 *       @param pathflags flags to control which files should be considered
 *               during the process search.
 *       @param buffer a C array of int-sized values to be filled with
 *               process identifiers that hold an open file reference
 *               matching the specified path or volume.  Pass NULL to
 *               obtain the minimum buffer size needed to hold the
 *               currently active processes.
 *       @param buffersize the size (in bytes) of the provided buffer.
 *       @result the number of bytes of data returned in the provided buffer;
 *               -1 if an error was encountered;
 */
int     proc_listpidspath(uint32_t      type,
    uint32_t      typeinfo,
    const char    *path,
    uint32_t      pathflags,
    void          *buffer,
    int           buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);

int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_listallpids(void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
int proc_listpgrppids(pid_t pgrpid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
int proc_listchildpids(pid_t ppid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_pidfdinfo(int pid, int fd, int flavor, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_pidfileportinfo(int pid, uint32_t fileport, int flavor, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
int proc_name(int pid, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_regionfilename(int pid, uint64_t address, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_kmsgbuf(void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_pidpath(int pid, void * buffer, uint32_t  buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
int proc_libversion(int *major, int * minor) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);

/*
 * Return resource usage information for the given pid, which can be a live process or a zombie.
 *
 * Returns 0 on success; or -1 on failure, with errno set to indicate the specific error.
 */
int proc_pid_rusage(int pid, int flavor, rusage_info_t *buffer) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);

/*
 * A process can use the following api to set its own process control
 * state on resoure starvation. The argument can have one of the PROC_SETPC_XX values
 */
#define PROC_SETPC_NONE         0
#define PROC_SETPC_THROTTLEMEM  1
#define PROC_SETPC_SUSPEND      2
#define PROC_SETPC_TERMINATE    3

int proc_setpcontrol(const int control) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
int proc_setpcontrol(const int control);

int proc_track_dirty(pid_t pid, uint32_t flags);
int proc_set_dirty(pid_t pid, bool dirty);
int proc_get_dirty(pid_t pid, uint32_t *flags);
int proc_clear_dirty(pid_t pid, uint32_t flags);

int proc_terminate(pid_t pid, int *sig);

#ifdef PRIVATE
#include <sys/event.h>
/*
 * Enumerate potential userspace pointers embedded in kernel data structures.
 * Currently inspects kqueues only.
 *
 * NOTE: returned "pointers" are opaque user-supplied values and thus not
 * guaranteed to address valid objects or be pointers at all.
 *
 * Returns the number of pointers found (which may exceed buffersize), or -1 on
 * failure and errno set appropriately.
 */
int proc_list_uptrs(pid_t pid, uint64_t *buffer, uint32_t buffersize);

int proc_list_dynkqueueids(int pid, kqueue_id_t *buf, uint32_t bufsz);
int proc_piddynkqueueinfo(int pid, int flavor, kqueue_id_t kq_id, void *buffer,
    int buffersize);
#endif /* PRIVATE */

int proc_udata_info(int pid, int flavor, void *buffer, int buffersize);

__END_DECLS

#endif /*_LIBPROC_H_ */

Bindgen Invocation

bindgen::Builder::default()
        .header("/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libproc.h")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .generate()
        .expect("Unable to generate bindings")
        .write_to_file(PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs"))
        .expect("Couldn't write bindings!");

Actual Results

   Compiling get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)
error: failed to run custom build command for `get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)`

Caused by:
  process didn't exit successfully: `/Users/camdennarzt/Developer/Rust/get_args/target/debug/build/get_args-88d57d09dbf528de/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=wrapper.h

--- stderr
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /usr/local/opt/llvm@10/lib/libclang.dylib could not be opened: dlopen(/usr/local/opt/llvm@10/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm23MCAsmParserSemaCallbackE\n  Referenced from: /usr/local/opt/llvm@10/lib/libclang.dylib\n  Expected in: /Users/camdennarzt/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib\n in /usr/local/opt/llvm@10/lib/libclang.dylib"', /Users/camdennarzt/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/lib.rs:1956:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1063
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:470
  11: rust_begin_unwind
             at src/libstd/panicking.rs:378
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  13: core::option::expect_none_failed
             at src/libcore/option.rs:1211
  14: core::result::Result<T,E>::expect
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/result.rs:961
  15: <bindgen::ensure_libclang_is_loaded::LIBCLANG as core::ops::deref::Deref>::deref::__static_ref_initialize
             at /Users/camdennarzt/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/lib.rs:1956
  16: core::ops::function::FnOnce::call_once
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/ops/function.rs:232
  17: lazy_static::lazy::Lazy<T>::get::{{closure}}
             at /Users/camdennarzt/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:31
  18: std::sync::once::Once::call_once::{{closure}}
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/sync/once.rs:264
  19: std::thread::local::fast::Key<T>::try_initialize
  20: std::sync::once::Once::call_once
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/sync/once.rs:264
  21: bindgen::CodegenConfig::contains
  22: bindgen::ensure_libclang_is_loaded
  23: bindgen::Bindings::generate
  24: bindgen::args_are_cpp::{{closure}}
  25: build_script_build::main
             at ./build.rs:35
  26: std::rt::lang_start::{{closure}}
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/rt.rs:67
  27: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  28: std::panicking::try::do_call
             at src/libstd/panicking.rs:303
  29: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  30: std::panicking::try
             at src/libstd/panicking.rs:281
  31: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  32: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  33: std::rt::lang_start
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/rt.rs:67
  34: build_script_build::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected Results

No panic.

@emilio
Copy link
Contributor

emilio commented May 13, 2020

It seems to be an error on libclang itself :/

Does opening it from another C program work at all?

@CamJN
Copy link
Author

CamJN commented May 13, 2020

Sorry I'm super tired ATM, can you be more specific as to what I'm supposed to open from another C program: libclang or bindgen or something else. And if at all possible a quick command to do so?

@emilio
Copy link
Contributor

emilio commented May 13, 2020

Np, understandable :)

Does the following work?

$ cat t.c
#include <dlfcn.h>
#include <stdio.h>

int main() {
  void* lib = dlopen("/usr/lib64/libclang.so", RTLD_NOW);
  printf("Success? %d", !!lib);
}
$ cc t.c -o t -ldl
$ ./t
Success? 1

Replacing /usr/lib64/libclang.so with /usr/local/opt/llvm@10/lib/libclang.dylib

@CamJN
Copy link
Author

CamJN commented May 13, 2020

Yup:

$ cat t.c
#include <dlfcn.h>
#include <stdio.h>

int main() {
  void* lib = dlopen("/usr/local/opt/llvm@10/lib/libclang.dylib", RTLD_NOW);
  printf("Success? %d", !!lib);
}
$ cc t.c -o t -ldl
$ ./t
Success? 1

I also checked compiling a few additional ways, which all give the same result:

  • xcrun cc t.c -o t -ldl
  • clang t.c -o t -ldl

@mojodna
Copy link

mojodna commented May 25, 2020

Installing llvm@9 and then running export LLVM_CONFIG_PATH=/usr/local/opt/llvm@9/bin/llvm-config before cargo build worked for me after experiencing this problem with llvm@10 (Homebrew's default version).

@duncaneddy
Copy link

I can also add that I ran into the same problem, and @mojodna's solution worked for me as well.

  • System: MacOS 10.15.4
  • Homebrew: 2.2.17-137-g43ae03d

To reproduce:

  1. brew install llvm which installs llvm: stable 10.0.0
  2. Use bindgen v0.54.0 to build project
  3. Get Error /usr/local/opt/llvm@10/lib/libclang.dylib could not be opened: dlopen(/usr/local/opt/llvm@10/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm23MCAsmParserSemaCallbackE

To solve:

  1. brew install llvm@9
  2. Build with LLVM_CONFIG_PATH=/usr/local/opt/llvm@9/bin/llvm-config cargo build

@kulp
Copy link
Member

kulp commented Jun 21, 2020

I can confirm that on my machine (macOS 10.14.6), I see that the Homebrew-bottled llvm loses the referenced symbol when upgrading from LLVM 9 to LLVM 10.

With llvm@9:

$ nm /usr/local/opt/llvm/lib/libclang.dylib | grep __ZTIN4llvm23MCAsmParserSemaCallbackE
00000000036c6108 s __ZTIN4llvm23MCAsmParserSemaCallbackE

After upgrading to llvm@10 :

$ nm /usr/local/opt/llvm/lib/libclang.dylib | grep __ZTIN4llvm23MCAsmParserSemaCallbackE
                 U __ZTIN4llvm23MCAsmParserSemaCallbackE

To me this looks like a libclang build issue, either by LLVM or by Homebrew.

@CamJN
Copy link
Author

CamJN commented Jul 17, 2020

error: failed to run custom build command for `get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)`

Caused by:
  process didn't exit successfully: `/Users/camdennarzt/Developer/Rust/get_args/target/debug/build/get_args-ebc1a5cf0e1888d4/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=wrapper.h

--- stderr
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /usr/local/opt/llvm@10/lib/libclang.dylib could not be opened: dlopen(/usr/local/opt/llvm@10/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm23MCAsmParserSemaCallbackE\n  Referenced from: /usr/local/opt/llvm@10/lib/libclang.dylib\n  Expected in: /Users/camdennarzt/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib\n in /usr/local/opt/llvm@10/lib/libclang.dylib"', /Users/camdennarzt/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/lib.rs:1956:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
brew info llvm
llvm: stable 10.0.0 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
/usr/local/Cellar/llvm/10.0.0_3 (7,055 files, 1GB)
  Poured from bottle on 2020-05-06 at 12:23:38
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb
==> Dependencies
Build: cmake ✘, [email protected] ✘
Required: libffi ✔
==> Requirements
Build: xcode ✘
==> Options
--HEAD
	Install HEAD version
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/camdennarzt/.bash_profile

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm/include"
rustc --version --verbose
rustc 1.45.0 (5c1f21c3b 2020-07-13)
binary: rustc
commit-hash: 5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2
commit-date: 2020-07-13
host: x86_64-apple-darwin
release: 1.45.0
LLVM version: 10.0

@emilio
Copy link
Contributor

emilio commented Jul 20, 2020

May be worth trying #1826.

@CamJN
Copy link
Author

CamJN commented Jul 28, 2020

@emilio #1826 gives me:

    Updating git repository `https://github.com/KyleMayes/rust-bindgen`
    Updating crates.io index
  Downloaded libloading v0.6.2
  Downloaded clang-sys v1.0.0
  Downloaded 2 crates (55.2 KB) in 0.67s
   Compiling libloading v0.6.2
   Compiling bindgen v0.54.1 (https://github.com/KyleMayes/rust-bindgen?branch=clang-sys-1.0.0#c31969df)
   Compiling clang-sys v1.0.0
   Compiling get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)
error: failed to run custom build command for `get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)`

Caused by:
  process didn't exit successfully: `/Users/camdennarzt/Developer/Rust/get_args/target/debug/build/get_args-2f206bf8d871a072/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=wrapper.h

--- stderr
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /usr/local/opt/llvm@10/lib/libclang.dylib could not be opened: dlopen(/usr/local/opt/llvm@10/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm23MCAsmParserSemaCallbackE\n  Referenced from: /usr/local/opt/llvm@10/lib/libclang.dylib\n  Expected in: /Users/camdennarzt/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib\n in /usr/local/opt/llvm@10/lib/libclang.dylib"', /Users/camdennarzt/.cargo/git/checkouts/rust-bindgen-06b02f9bd008e0d0/c31969d/src/lib.rs:1846:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@CamJN
Copy link
Author

CamJN commented Aug 15, 2020

More investigation:

$ cargo build
   Compiling get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)
error: failed to run custom build command for `get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)`

Caused by:
  process didn't exit successfully: `/Users/camdennarzt/Developer/Rust/get_args/target/debug/build/get_args-f8acb7fc471780f2/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=wrapper.h

--- stderr
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /usr/local/opt/llvm/lib/libclang.dylib could not be opened: dlopen(/usr/local/opt/llvm/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm13ErrorInfoBaseE\n  Referenced from: /usr/local/opt/llvm/lib/libclang.dylib\n  Expected in: /Users/camdennarzt/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib\n in /usr/local/opt/llvm/lib/libclang.dylib"', /Users/camdennarzt/.cargo/git/checkouts/rust-bindgen-06b02f9bd008e0d0/c31969d/src/lib.rs:1846:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

$ echo __ZTIN4llvm13ErrorInfoBaseE | c++filt
typeinfo for llvm::ErrorInfoBase

$ /usr/local/Cellar/llvm/10.0.1/bin/llvm-config --has-rtti
YES

$ nm /usr/local/opt/llvm/lib/libclang.dylib | fgrep __ZTIN4llvm13ErrorInfoBaseE
                 U __ZTIN4llvm13ErrorInfoBaseE

$ find /usr/local/opt/llvm/ -type f -exec sh -c "nm {} 2>/dev/null | egrep '[^U] __ZTIN4llvm13ErrorInfoBaseE'" \; -print
000000010022bab0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//bin/llvm-tblgen
000000010003cdd0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//bin/lli-child-target
00000001000369c0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//bin/yaml-bench
000000010005aca0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//bin/FileCheck
0000000002f22aa0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//lib/libLLVM.dylib
00000000000027e8 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//lib/libLLVMSupport.a
000000010022bab0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//Toolchains/LLVM10.0.1.xctoolchain/usr/bin/llvm-tblgen
000000010003cdd0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//Toolchains/LLVM10.0.1.xctoolchain/usr/bin/lli-child-target
00000001000369c0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//Toolchains/LLVM10.0.1.xctoolchain/usr/bin/yaml-bench
000000010005aca0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//Toolchains/LLVM10.0.1.xctoolchain/usr/bin/FileCheck
0000000002f22aa0 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//Toolchains/LLVM10.0.1.xctoolchain/usr/lib/libLLVM.dylib
00000000000027e8 S __ZTIN4llvm13ErrorInfoBaseE
/usr/local/opt/llvm//Toolchains/LLVM10.0.1.xctoolchain/usr/lib/libLLVMSupport.a

It looks like the symbol is defined in /usr/local/opt/llvm//lib/libLLVM.dylib and /usr/local/opt/llvm//lib/libLLVMSupport.a, how can I get bindgen to link one of those?

Also apparently the missing symbol changed.

@kulp
Copy link
Member

kulp commented Aug 15, 2020

It looks like the symbol is defined in /usr/local/opt/llvm//lib/libLLVM.dylib and /usr/local/opt/llvm//lib/libLLVMSupport.a, how can I get bindgen to link one of those?

@CamJN, what happens if you try setting DYLD_INSERT_LIBRARIES in your environment ? For example,

DYLD_INSERT_LIBRARIES=/usr/local/opt/llvm/lib/libLLVM.dylib cargo build

@CamJN
Copy link
Author

CamJN commented Aug 25, 2020

@kulp

$ DYLD_INSERT_LIBRARIES=/usr/local/opt/llvm/lib/libLLVM.dylib cargo build
   Compiling get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)
error: failed to run custom build command for `get_args v0.1.0 (/Users/camdennarzt/Developer/Rust/get_args)`

Caused by:
  process didn't exit successfully: `/Users/camdennarzt/Developer/Rust/get_args/target/debug/build/get_args-f8acb7fc471780f2/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=wrapper.h

--- stderr
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /usr/local/opt/llvm/lib/libclang.dylib could not be opened: dlopen(/usr/local/opt/llvm/lib/libclang.dylib, 2): Symbol not found: __ZTIN4llvm13ErrorInfoBaseE\n  Referenced from: /usr/local/opt/llvm/lib/libclang.dylib\n  Expected in: /Users/camdennarzt/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libLLVM.dylib\n in /usr/local/opt/llvm/lib/libclang.dylib"', /Users/camdennarzt/.cargo/git/checkouts/rust-bindgen-06b02f9bd008e0d0/c31969d/src/lib.rs:1846:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@kulp
Copy link
Member

kulp commented Aug 28, 2020

Well, I am out of ideas, then :(

@CamJN
Copy link
Author

CamJN commented Sep 14, 2020

Problem persists with bindgen v0.55.1.

@CamJN
Copy link
Author

CamJN commented Nov 25, 2020

The the following combo of versions works:

bindgen v0.55.1
homebrew's LLVM 11.0.0 
rustc 1.48.0 (7eac88abb 2020-11-16)

@CamJN CamJN closed this as completed Nov 25, 2020
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

No branches or pull requests

5 participants