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

Importing rustc_driver interferes with rustc_codegen_llvm items and leads to a linking error #102065

Open
hkmatsumoto opened this issue Sep 20, 2022 · 3 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue

Comments

@hkmatsumoto
Copy link
Member

hkmatsumoto commented Sep 20, 2022

I tried this code, which builds and runs without problem:

#![feature(rustc_private)]

extern crate rustc_codegen_llvm;
extern crate rustc_errors;
extern crate rustc_interface;
extern crate rustc_llvm;
extern crate rustc_session;
extern crate rustc_span;
extern crate rustc_driver;

use std::{path::PathBuf, process::Command};

use rustc_codegen_llvm::llvm::*;

fn config() -> rustc_interface::Config {
    let sysroot = Command::new("rustc")
        .arg("--print=sysroot")
        .output()
        .unwrap();
    let sysroot = std::str::from_utf8(&sysroot.stdout).unwrap().trim();

    rustc_interface::Config {
        opts: rustc_session::config::Options {
            maybe_sysroot: Some(PathBuf::from(sysroot)),
            ..Default::default()
        },
        crate_cfg: Default::default(),
        crate_check_cfg: Default::default(),
        input: rustc_session::config::Input::Str {
            name: rustc_span::FileName::Anon(0),
            input: "".to_owned(),
        },
        input_path: Default::default(),
        output_file: Default::default(),
        output_dir: Default::default(),
        file_loader: Default::default(),
        diagnostic_output: rustc_session::DiagnosticOutput::Default,
        lint_caps: Default::default(),
        parse_sess_created: Default::default(),
        register_lints: Default::default(),
        override_queries: Default::default(),
        make_codegen_backend: Default::default(),
        registry: rustc_errors::registry::Registry::new(&[]),
    }
}

fn main() {
    rustc_llvm::initialize_available_targets();

    rustc_interface::run_compiler(config(), |compiler| {
        compiler.enter(|queries| {
            queries.global_ctxt().unwrap().peek_mut().enter(|_| unsafe {
                let llcx = LLVMRustContextCreate(false);
                LLVMContextDispose(llcx);
            })
        })
    })
}

However, after I make this change:

diff --git a/src/main.rs b/src/main.rs
index abbe4d5..3de7673 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,7 @@
 #![feature(rustc_private)]
 
 extern crate rustc_codegen_llvm;
+extern crate rustc_driver;
 extern crate rustc_errors;
 extern crate rustc_interface;
 extern crate rustc_llvm;

I expected to see this happen: The compiler builds without errors.

Instead, this happened: cargo build fails with the message shown in "Output" section below.

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (2019147c5 2022-09-19)
binary: rustc
commit-hash: 2019147c5642c08cdb9ad4cacd97dd1fa4ffa701
commit-date: 2022-09-19
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0
Output

   Compiling rustc-llvm-error v0.1.0 (/rustc-llvm-error)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcUa2Iji/symbols.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.12xtlng5ng7yz38c.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.13athc1kp4ff5lqu.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.13qod15sbbzwg5sn.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.143fdd4rkuyguge3.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.150lyks3tmsuq9g2.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.15tdfwby05lsftxd.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.18070mtialcocyox.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.184cjb9g3i3mp7uy.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1bu527l2qlssuw01.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1dact2rc5efb42hq.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1dc84u95mkmm6j6c.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1e4e3hzk6wnguyi1.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1emn87a8flqdt5jj.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1f1si8401eqnicvm.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1h82plhpofac30es.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1itu1z4ot8pcpcqf.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1ixloxag7bhc8ddg.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1jeg1h5kv0acad79.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1lrxotruvsb3j1l5.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1nfoeg01qy90t5re.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1nv060tnj7zm5t2l.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1oeaqk1brunib4u.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1q1fy3z8zlu99j1l.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1qpo2uy87m328ppv.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1qpsj8hoc6pz4nkp.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1r4x5olvbed8wjku.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1srdyia98rqe18ts.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1u39prg7wrb0mb22.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1wgtlqk4ctr3vqto.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1wsqgmtf15zvnx9h.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1y7dkk3gh8ut85j6.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1ygyxuq2v9ismur8.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1ytggfzqr1k13mcs.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1zmajzhbplum1hn5.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.201vzzoi8i36piob.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.20iven9j1hdmqnco.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.20uk0ppobk58khd0.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.22vrd9lshif8c4g3.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.23xlm379rs7kr9cz.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.251ioo1kvqod76o8.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.27rabhtwy43771lf.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.29dku44uekojk5bc.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2a2bewcy8mwm16ro.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2b4zntc1x4em9gok.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2cs9q1q61wev2wrm.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2cu5c4gbzighoxj7.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2gmxp68rse5es5vc.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2gpqswuuscmxh8ge.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2lygpt69ln86calj.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2nwcltd9aulzfdvm.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2pk0cifpn3ky2ggu.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2r0dobxcm62om7ej.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2rvi6darqitmy9r7.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2u8u0ucde5umk0ns.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2uz6t6taie0kpmik.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2vd47qesewdaic9f.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2vwpg0ue48tqydcl.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2y50u1zv002h52wt.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.2y8afb5t0y4cpx5j.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.305fi5at0ap78uzk.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.30k2zp46vtiu0zh6.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.30yewo485je2dh57.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.31b90qj8khmir75s.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.31un8cj8uodxg2wq.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.32bai3qupe1bly7u.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.32knr1sby6irujpj.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.334rgpwjrkw7kr78.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.34cer2s49fefh2st.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.359f08q8b5dycmrx.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.35r108fzgx57v7yk.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.369nm53r7kxim00f.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.369x7oq70k8sl6ak.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.36ewyffz9g196jrc.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.38d3trvt4brmpg7b.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.38ntzbx6whvf9adh.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3a8k3nbdv8ieegw2.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3axg6wsaj9cr7rjz.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3bp96yq6jtyj50q5.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3ccohn20xipz2i4k.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3cim6g8dqq44xusr.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3eecea7mgh4ud09m.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3ew6k8kh0zcler6m.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3fnyn0qaj81md1zo.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3h3byvfhkcgbjj2m.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3hk1mfj71i7xlltw.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3hnolg1tt6cppiee.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3iqkf8ux9whenst.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3j6im5n5adh5ogg8.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3jfdo5zraxum28yu.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3km0xcn3fdezjsxk.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3mb7vb64ocyh0zlr.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3monetxxax1j7q5w.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3parkhbodouoqasj.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3pct3jjp9z2916vi.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3rbti3mosq6k4i.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3sucyzmn2igapk7s.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3sviqxgv6o88y82o.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3tmc5dfeikmbqmei.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3tu1ug5nb3bqw62u.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3u62oslpl8t0tul7.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3v0v6dsxraqtub4d.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3v9booyaqezd37ex.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3w2z0lvjajxghz07.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3xgkyibebj5mb2mc.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3y9f04tv6pt4zjxm.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3ydwxic87xk79jfw.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.3z470i5s7499m1bb.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.40m9xkt0u3tdodif.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.42a6v1godc7bsyxt.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.42i5loy76inan0qo.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.42ui8bpxki2sfb3p.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.43po215isxykkv8r.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.448mos34moywxczs.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.45qgy7q7cepk5hj5.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.471ri46t61ed4qds.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.47ygykuc5jil4i0l.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.48k9jkwl4hld3jco.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.48wxchhflkgjra8g.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.49wsayjduaq0qj0h.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4ba2qdxmsuu4rgb0.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4bwk4bk8vzg85v59.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4cc5jf9ga558in63.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4dcnm0s8ra53wbsp.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4dikfiz3q86fat1m.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4e4vhgyqxqxuk5i4.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4enioro6k3h9ntbk.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4eyyjw9hnmf99mt6.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4g743rlimbm39485.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4gk0bi376odr5am1.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4hinj5k0jqlirvz.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4i3k1x3baitkanxs.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4ie2mv0f1p9mslso.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4m0ryksef5169z8t.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4meug47mugwy62l0.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4mtyk6btdar37ltf.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4ncyfwlre7uq7gm7.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4oqwaeed66e266l4.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4p9hprkbvc3rp83f.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4poban9drx6ifz8t.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4puahmnbrb4072bg.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4qdjpc6uhrv8rclu.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4rnvzhnvrqtnn46h.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4s76moyuw5ajldtw.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4sb987unlqfdmmac.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4seb18swarlit0nc.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4udji8x96zprehb0.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.4uepepei8qp6uavz.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.52g2l5wyerp5i7d0.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.53djzsqyv1n08onk.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.54cekgknqnlie6qe.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.55fngmtkbga8i46l.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.55ypkgwnmx24x88h.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.56rzgs9yao8milw7.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.57g1y3t9dz0xl1hw.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.59bmwzxjs87488e5.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.5a45h250qmme1zg4.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.5bshk15qbc2lagfm.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.5ebyjpgxwsq2hx7b.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.7s94pavdkfdj725.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.8h9cz66z2p7uzs6.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.akgegtnpjvtqvl.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.b6onjql2dwr63xo.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.bpba17kgm1mqyt4.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.cnth2wgkjq9ar6c.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.do40frwixg0lwhq.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.duxhhifopbook0j.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.ekmovqz1cyl8lzx.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.ft1iy21z3sp2aak.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.ftrriimametv7up.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.h6bw9ojic34abe4.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.k1hsx2y3qeetj1u.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.kvvpshc2m4o0yl2.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.mdlgutnzk1if1o2.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.mm2xnrljhlhjuab.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.rqikyzl9ffpqfxe.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.rxb34vwptazif0e.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.tnj82djluh0u0p5.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.tso8dgxe1resdlw.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.wikeedfj7lwo3q0.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.xtk7tuct6far52a.rcgu.o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.zj7r7tzv4az9znm.rcgu.o" "-Wl,--as-needed" "-L" "/rustc-llvm-error/target/debug/deps" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_driver-fc29f38e0694ba72" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-3dd5f78c3b43746e" "-Wl,-Bstatic" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-5b83a1df856cf582.rlib" "-Wl,-Bdynamic" "-lLLVM-15-rust-1.66.0-nightly" "-ldl" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /rustc-llvm-error/target/debug/deps/rustc_llvm_error-08eddc3003b44883.1nv060tnj7zm5t2l.rcgu.o: in function `rustc_llvm_error::main::{{closure}}::{{closure}}::{{closure}}':
          /rustc-llvm-error/src/main.rs:53: undefined reference to `LLVMRustContextCreate'
          collect2: error: ld returned 1 exit status
          
  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `rustc-llvm-error` due to previous error

@hkmatsumoto hkmatsumoto added the C-bug Category: This is a bug. label Sep 20, 2022
@hkmatsumoto
Copy link
Member Author

hkmatsumoto commented Sep 20, 2022

The entire code is available here, Dockerfile included.

@hkmatsumoto
Copy link
Member Author

I managed to minimize the code:

#![feature(rustc_private)]

extern crate rustc_codegen_llvm;
extern crate rustc_driver;

fn main() {
    unsafe {
        rustc_codegen_llvm::llvm::LLVMRustContextCreate(true);
    }
}

@hkmatsumoto hkmatsumoto added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Sep 20, 2022
@cuviper
Copy link
Member

cuviper commented Sep 20, 2022

In rustc_llvm, that's originally a global symbol:

$ readelf -Ws librustc_llvm-*.rlib | grep LLVMRustContextCreate
    38: 0000000000000000     0 SECTION LOCAL  DEFAULT   61 .text.LLVMRustContextCreate
   259: 0000000000000000    51 FUNC    GLOBAL DEFAULT   61 LLVMRustContextCreate

But the one linked into librustc_driver.so gets hidden as a local symbol:

$ readelf -Ws librustc_driver-*.so | grep LLVMRustContextCreate
117293: 0000000000c2ad60    51 FUNC    LOCAL  DEFAULT   11 LLVMRustContextCreate

I notice that the link line does not include librustc_llvm.rlib though, only -lrustc_driver-*.

Manishearth added a commit to Manishearth/rust that referenced this issue Nov 14, 2022
…imulacrum

Add a few known-bug tests

The labels of these tests should be changed from `S-bug-has-mcve` to `S-bug-has-test` once this is merged.

cc:
rust-lang#101518
rust-lang#99492
rust-lang#90950
rust-lang#89196
rust-lang#104034
rust-lang#101350
rust-lang#103705
rust-lang#103899

I couldn't reproduce the failures in rust-lang#101962 and rust-lang#100772 (so either these have started passing, or I didn't repro properly), so leaving those out for now.

rust-lang#102065 was a bit more complicated, since it uses `rustc_private` and I didn't want to mess with that.
@workingjubilee workingjubilee added A-linkage Area: linking into static, shared libraries and binaries S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. labels Mar 4, 2023
hkmatsumoto added a commit to rustc-interactive/rust that referenced this issue Mar 31, 2023
If `interactive` is set to true, codegen will special case that to get
faster and for the resulting LLVM IR to be executable from external
programs such as REPL.

This commit also has the following changes:

- Added LLVM JIT-related API.

- Stopped distributing rustc crates as rmeta files. See added code
  comment and rust-lang#102065 for detailed info.

- Some visibility changes on existing APIs so they could be used by
  external programs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue
Projects
None yet
Development

No branches or pull requests

3 participants