You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
externcrate common;fnmain(){println!("driver: {:p}", common::get as*const());// You can comment this line to make it work.assert_eq!(common::get(),&common::STATICas*const _);unsafe{extern"C"{fndlopen(filename:*constu8,flag:i32) -> *mutu8;fndlsym(handle:*mutu8,symbol:*constu8) -> *constu8;}
std::mem::transmute::<*constu8,fn()>(dlsym(dlopen(b"./libplugin.so\0".as_ptr(),1),b"run\0".as_ptr(),))()}}
How to run it:
RELEASE=nightly-2018-10-11
rustup toolchain add $RELEASEecho'System toolchain versions:'
ldd --version | head -n1 | sed 's/^ldd //'
ld.bfd --version | head -n1
ld.gold --version | head -n1
echo
rustc +$RELEASE common.rs --crate-type=lib
# You can change this from dylib to cdylib to make it work.
rustc +$RELEASE plugin.rs --crate-type=dylib -L.
# You can uncomment -Z plt=yes to make it work.
rustc +$RELEASE driver.rs -L. # -Z plt=yes
./driver
I was able to try this out with NixOS 18.03 and 18.09 releases, via:
Originally reported as #60593, and appears to be caused by #54592, this is my reduction:
common.rsplugin.rsdriver.rsHow to run it:
I was able to try this out with NixOS 18.03 and 18.09 releases, via:
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.03.tar.gz \ nix-shell -p stdenv --run ./test.sh NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.09.tar.gz \ nix-shell -p stdenv --run ./test.shExample of failure (using a NixOS 18.03 toolchain):
Example of success (by switching to NixOS 18.09):
Other ways to get it to succeed:
RELEASE=nightly-2018-10-11)-Z plt=yeswhen compilingdriverplugintocdylib(instead ofdylib)common::getis private in that case?cdylibcommon::getindrivercommon::getwon't get looked up early, which meansdriver's copy won't overrideplugin's (within the context of affected toolchains)RTLD_DEEPBINDwhen callingdlopencommon::getfromdriveris ignored when looking up the use fromplugincc @alexcrichton @rust-lang/compiler