-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Long debug session short:
- Having a proc-macro crate with tests works.
- Adding nom 5 as a dependency to a proc-macro crate works.
- Having nom 5 be a dependency in a proc-macro crate with tests does not work.
This might be a known problem; I couldn't find an open issue, though. Even so, error is not user friendly and that should at least be fixed.
cargo test --verbose
Fresh semver-parser v0.7.0
Fresh void v1.0.2
Fresh version_check v0.1.5
Fresh static_assertions v0.2.5
Fresh cfg-if v0.1.9
Fresh semver v0.9.0
Fresh rustc_version v0.2.3
Fresh unreachable v1.0.0
Fresh ryu v0.2.8
Fresh memchr v2.2.0
Fresh stackvector v1.0.6
Fresh lexical-core v0.4.2
Fresh nom v5.0.0
Compiling le-proc-macro v0.1.0 (/Users/pascal/Projekte/rust-proc-macro-test-linking-error/le-proc-macro)
Running `rustc --edition=2018 --crate-name le_proc_macro le-proc-macro/src/lib.rs --color always --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=88a723aab0e69935 -C extra-filename=-88a723aab0e69935 --out-dir /Users/pascal/.cargo/global-target/debug/deps -C incremental=/Users/pascal/.cargo/global-target/debug/incremental -L dependency=/Users/pascal/.cargo/global-target/debug/deps --extern nom=/Users/pascal/.cargo/global-target/debug/deps/libnom-1f917ff11a098652.rlib -Zsymbol-mangling-version=v0`
Running `rustc --edition=2018 --crate-name le_proc_macro le-proc-macro/src/lib.rs --color always --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 --test -C metadata=a6088ffbe5f8f402 -C extra-filename=-a6088ffbe5f8f402 --out-dir /Users/pascal/.cargo/global-target/debug/deps -C incremental=/Users/pascal/.cargo/global-target/debug/incremental -L dependency=/Users/pascal/.cargo/global-target/debug/deps --extern nom=/Users/pascal/.cargo/global-target/debug/deps/libnom-1f917ff11a098652.rlib -Zsymbol-mangling-version=v0`
warning: unused import: `nom::IResult`
--> le-proc-macro/src/lib.rs:4:5
|
4 | use nom::IResult;
| ^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
warning: unused import: `nom::IResult`
--> le-proc-macro/src/lib.rs:4:5
|
4 | use nom::IResult;
| ^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-m64" "-L" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.15tcejuoevmooxrp.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.2t5ie6p57602b1hc.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.3k5tdhzyfh385jbb.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.40gtnqu5cs3dsn54.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.4qorxw028kxfrme3.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.52k0bg5o47l9e5g5.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.al00ie0yzyrbvcs.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.mt4xvaos1670dho.rcgu.o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402.uo2b4vausxznfy0.rcgu.o" "-o" "/Users/pascal/.cargo/global-target/debug/deps/le_proc_macro-a6088ffbe5f8f402" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/pascal/.cargo/global-target/debug/deps" "-L" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-ltest-0d2e540bfeb389c9" "-L" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-lterm-9dc2d4db7993fbfd" "/Users/pascal/.cargo/global-target/debug/deps/libnom-1f917ff11a098652.rlib" "-L" "/Users/pascal/.cargo/global-target/debug/deps" "-llexical_core-d715db2534c4793d" "/Users/pascal/.cargo/global-target/debug/deps/libryu-aa307abc73a251bb.rlib" "/Users/pascal/.cargo/global-target/debug/deps/libstackvector-8faea803e8d71d93.rlib" "/Users/pascal/.cargo/global-target/debug/deps/libunreachable-5224a131bd9f1445.rlib" "/Users/pascal/.cargo/global-target/debug/deps/libvoid-196f5b851425c571.rlib" "/Users/pascal/.cargo/global-target/debug/deps/libstatic_assertions-633d173cf8830653.rlib" "/Users/pascal/.cargo/global-target/debug/deps/libcfg_if-3eb3c0e2c877bcb6.rlib" "/Users/pascal/.cargo/global-target/debug/deps/libmemchr-affb19acc32f58a0.rlib" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libproc_macro-027ee96af4731d93.rlib" "-L" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-lstd-a62aa059e97bb248" "/Users/pascal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-a62aa322f1655fc7.rlib" "-lSystem" "-lresolv" "-lc" "-lm"
= note: Undefined symbols for architecture x86_64:
"__RNvXsJ_NtCs6GOKu7pHlyt_4core3fmtRlNtB5_5Debug3fmtCs7N6e5JiROWN_12lexical_core", referenced from:
__RINvCsLl3UznTzjj_4test18assert_test_resultuECsfbY9ZosDsBF_13le_proc_macro in le_proc_macro-a6088ffbe5f8f402.al00ie0yzyrbvcs.rcgu.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
error: Could not compile `le-proc-macro`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name le_proc_macro le-proc-macro/src/lib.rs --color always --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 --test -C metadata=a6088ffbe5f8f402 -C extra-filename=-a6088ffbe5f8f402 --out-dir /Users/pascal/.cargo/global-target/debug/deps -C incremental=/Users/pascal/.cargo/global-target/debug/incremental -L dependency=/Users/pascal/.cargo/global-target/debug/deps --extern nom=/Users/pascal/.cargo/global-target/debug/deps/libnom-1f917ff11a098652.rlib -Zsymbol-mangling-version=v0` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed
See these commits for a minimal repo: https://github.com/killercup/rust-proc-macro-test-linking-error/commits/master
Tested with rustc 1.37.0-nightly (7840a0b75 2019-05-31)
and rustc 1.35.0 (3c235d560 2019-05-20)
.
cc @fry because we originally encountered this issue in https://github.com/fry/memory-offset-match
cc @Geal because he might have done something horrible in nom 5 or one of its dependencies :)
rylev and CAD97
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.