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

Fail to build on windows when used in a dylib #1066

Closed
breard-r opened this issue Nov 10, 2019 · 2 comments
Closed

Fail to build on windows when used in a dylib #1066

breard-r opened this issue Nov 10, 2019 · 2 comments

Comments

@breard-r
Copy link
Contributor

Environment

rustc 1.39.0
cargo 1.39.0
Windows 10
Visual Studio 2019

Bug description

If nom is used within a library which uses the "dylib" crate-type (even in conjunction with other types), then every binary having this lib as a dependency will fail to compile on windows (error log below).

Example project

The library (named what)

The library's Cargo.toml must contain:

[lib]
crate-type = ["rlib", "staticlib", "dylib"]

[dependencies]
nom = "^5.0"

Also, lib.rs, must contain any call to nom:

use nom::IResult;

There is no need to actually use IResult.

The binary (named nom_test)

The Cargo.toml must include a dependency to the above library:

what = { path = "../what" }

Full compilation error log

   Compiling what v0.1.0 (C:\Users\IEUser\Documents\what)
warning: unused import: `nom::IResult`
 --> C:\Users\IEUser\Documents\what\src\lib.rs:1:5
  |
1 | use nom::IResult;
  |     ^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\IEUser\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps\\what.21gzt9dmql5wpjdr.rcgu.o" "C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps\\what.4ystgd986jq7yk2.rcgu.o" "C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps\\what.536gldm0y7j9385e.rcgu.o" "/OUT:C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps\\what.dll" "/DEF:C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\lib.def" "C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps\\what.410mx9jdkl3q5zc9.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\IEUser\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\IEUser\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\IEUser\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps" "/LIBPATH:C:\\Users\\IEUser\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libnom-e6cd95662c3de3c0.rlib" "/LIBPATH:C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps" "lexical_core-884f3250c93671c7.dll.lib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libryu-e0c896779a9a83b2.rlib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libarrayvec-e7ab9ba56c4e4f0b.rlib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libnodrop-b91803cad2fc5675.rlib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libstatic_assertions-1e43b9025a557ea6.rlib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libcfg_if-ab2d56b908afceb8.rlib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libmemchr-42655e9897b691a0.rlib" "/LIBPATH:C:\\Users\\IEUser\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "std-f3cd9033b21bfd69.dll.lib" "C:\\Users\\IEUser\\AppData\\Local\\Temp\\rustcVWsdcC\\libcompiler_builtins-b32ee8ba444e5f7c.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib" "/DLL" "/IMPLIB:C:\\Users\\IEUser\\Documents\\nom_test\\target\\debug\\deps\\what.dll.lib"
  = note: lib.def : error LNK2001: unresolved external symbol _ZN103_$LT$core..ops..range..RangeFrom$LT$usize$GT$$u20$as$u20$core..slice..SliceIndex$LT$$u5b$T$u5d$$GT$$GT$5index17h16dfd957a24be96aE
          lib.def : error LNK2001: unresolved external symbol _ZN119_$LT$core..ptr..non_null..NonNull$LT$T$GT$$u20$as$u20$core..convert..From$LT$core..ptr..unique..Unique$LT$T$GT$$GT$$GT$4from17h89a9f9c5de914c55E
          lib.def : error LNK2001: unresolved external symbol _ZN36_$LT$T$u20$as$u20$core..any..Any$GT$7type_id17h384e3ea937c2f50fE
          lib.def : error LNK2001: unresolved external symbol _ZN36_$LT$T$u20$as$u20$core..any..Any$GT$7type_id17h7fc674de8ed1cdc9E
          lib.def : error LNK2001: unresolved external symbol _ZN3std9panicking11begin_panic17hd5fad2e5b1cb1a1eE
          lib.def : error LNK2001: unresolved external symbol _ZN3std9panicking11begin_panic21PanicPayload$LT$A$GT$3new17hef501abab009e17eE
          lib.def : error LNK2001: unresolved external symbol _ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h18fdf6c968c79186E
          lib.def : error LNK2001: unresolved external symbol _ZN4core10intrinsics19copy_nonoverlapping17h5dfb380fe53d1501E
          lib.def : error LNK2001: unresolved external symbol _ZN4core10intrinsics23is_aligned_and_not_null17h32d7b0ae14b93d23E
          lib.def : error LNK2001: unresolved external symbol _ZN4core10intrinsics8overlaps17h5b2a4999cfde967bE
          lib.def : error LNK2001: unresolved external symbol _ZN4core3any6TypeId2of17he11cab35faa72363E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3any6TypeId2of17hf4a4ea178c665263E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3cmp3Ord3min17he307c5d23a0c77d9E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3cmp3min17h8082ded06c8134d0E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3cmp6min_by17h92d499d5cf702d53E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3mem4swap17hcfc34b75b331ded5E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3mem4take17hd02550b66ad831d7E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3mem6forget17hb71d01f4f28d6ff8E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3mem7replace17he9c0c6c009654817E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3mem7size_of17h066feda5197c8b60E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3mem8align_of17he7ae9c2430603a73E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr19swap_nonoverlapping17h30898c996d3605f7E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr20slice_from_raw_parts17h5c19352175429477E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr23swap_nonoverlapping_one17hf26f8220621dfd23E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr31_$LT$impl$u20$$BP$mut$u20$T$GT$7is_null17h131fd289da081c14E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr33_$LT$impl$u20$$BP$const$u20$T$GT$7is_null17hb4e30fc4c0b5c461E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr4read17h04ddc01916fc6c9bE
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr5write17h11c6de3191122556E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr6unique15Unique$LT$T$GT$13new_unchecked17h008cad084dc4212cE
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr6unique15Unique$LT$T$GT$6as_mut17hdbbb0492e159b5a4E
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr6unique15Unique$LT$T$GT$6as_ptr17hb23d53398fb82e2dE
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr8non_null16NonNull$LT$T$GT$13new_unchecked17h5aba2e1c8c2214bfE
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr8non_null16NonNull$LT$T$GT$6as_ptr17h7c0cb9399d57e0faE
          lib.def : error LNK2001: unresolved external symbol _ZN4core3ptr8null_mut17hac58237611c95394E
          lib.def : error LNK2001: unresolved external symbol _ZN4core5slice14from_raw_parts17hefbe2a363f9a0ac2E
          lib.def : error LNK2001: unresolved external symbol _ZN4core5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$3len17h63a6ba86fedf4ffbE
          lib.def : error LNK2001: unresolved external symbol _ZN4core5slice74_$LT$impl$u20$core..ops..index..Index$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$5index17h68d505aeca290394E
          lib.def : error LNK2001: unresolved external symbol _ZN4core6option15Option$LT$T$GT$4take17ha4e9fe2eb255ebedE
          lib.def : error LNK2001: unresolved external symbol _ZN4core6option15Option$LT$T$GT$9unwrap_or17hdd33111455cfed68E
          lib.def : error LNK2001: unresolved external symbol _ZN50_$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$4into17hc75abfbb7ed51de0E
          lib.def : error LNK2001: unresolved external symbol _ZN5alloc5alloc8box_free17hf2574532d25eb9beE
          lib.def : error LNK2001: unresolved external symbol _ZN5alloc5boxed12Box$LT$T$GT$11into_unique17h93d1877b33e2f269E
          lib.def : error LNK2001: unresolved external symbol _ZN5alloc5boxed12Box$LT$T$GT$17into_raw_non_null17hfe099315ba78b300E
          lib.def : error LNK2001: unresolved external symbol _ZN5alloc5boxed12Box$LT$T$GT$8into_raw17he201d4b0bfe66189E
          lib.def : error LNK2001: unresolved external symbol _ZN72_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..default..Default$GT$7default17h7b8770ce01dcae31E
          lib.def : error LNK2001: unresolved external symbol _ZN91_$LT$std..panicking..begin_panic..PanicPayload$LT$A$GT$$u20$as$u20$core..panic..BoxMeUp$GT$3get17ha86b718c4b23c764E
          lib.def : error LNK2001: unresolved external symbol _ZN91_$LT$std..panicking..begin_panic..PanicPayload$LT$A$GT$$u20$as$u20$core..panic..BoxMeUp$GT$9box_me_up17h3defa3b7bc405d54E
          lib.def : error LNK2001: unresolved external symbol _ZN99_$LT$core..ops..range..Range$LT$usize$GT$$u20$as$u20$core..slice..SliceIndex$LT$$u5b$T$u5d$$GT$$GT$13get_unchecked17hccd0549b05e1fe96E
          lib.def : error LNK2001: unresolved external symbol _ZN99_$LT$core..ops..range..Range$LT$usize$GT$$u20$as$u20$core..slice..SliceIndex$LT$$u5b$T$u5d$$GT$$GT$5index17hbf931ef3b3280edaE
          C:\Users\IEUser\Documents\nom_test\target\debug\deps\what.dll.lib : fatal error LNK1120: 49 unresolved externals
          

error: aborting due to previous error

error: could not compile `what`.

To learn more, run the command again with --verbose.
@Alexhuszagh
Copy link
Contributor

Duplicate of downstream issue:
Alexhuszagh/rust-lexical#29

Should be fixed with a PR to upgrade lexical in Nom to v0.6+.

Thanks for reporting.

Alexhuszagh added a commit to Alexhuszagh/nom that referenced this issue Jan 7, 2020
Geal pushed a commit that referenced this issue Feb 24, 2020
Patches:
- #1100
- #1080
- #1066
- And a few upstream issues.
@Geal
Copy link
Collaborator

Geal commented Feb 24, 2020

#1101 is merged, new version coming up

@Geal Geal closed this as completed Feb 24, 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

3 participants