rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.07k stars 1.04k forks source link

A recent change may have broken badboy/rust-triangle-js #752

Closed elidupree closed 5 years ago

elidupree commented 7 years ago

If this was an intentional breaking change, I apologize for the inconvenience, but I'd like to know so I can fix it on the badboy/backtrace-rs emscripten-fix end. (A project of mine is currently dependent on that for its emscripten builds.)

The error:

error[E0308]: mismatched types 
  --> /n/HOME/.cargo/git/checkouts/backtrace-rs-2d807a33d0b45dd4/7eb1cdc/src/dylib.rs:27:32 
   | 
27 |         let ptr = libc::dlopen(name.as_ptr(), libc::RTLD_LAZY); 
   |                                ^^^^^^^^^^^^^ expected i8, found u8 
   | 
   = note: expected type `*const i8` 
              found type `*const u8` 
   = help: here are some functions which might fulfill your needs: 
           - .offset(...) 
           - .wrapping_offset(...) 

Full build log (First a working build, then cargo update leading to a broken one):

eli@thoth:/n/backup_often/rust-triangle-js$ cargo build --target=asmjs-unknown-emscripten                 
warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#glutin:0.6.1 
   Compiling rustc-serialize v0.3.24 
   Compiling cfg-if v0.1.2 
   Compiling winapi v0.2.8 
   Compiling rustc-demangle v0.1.4 
   Compiling bitflags v0.9.1 
   Compiling lazy_static v0.2.8 
   Compiling libc v0.2.26 
   Compiling backtrace v0.2.3 (https://github.com/badboy/backtrace-rs?branch=emscripten-fix#7eb1cdcd) 
   Compiling winapi-build v0.1.1 
   Compiling khronos_api v1.0.1 
   Compiling smallvec v0.1.8 
   Compiling num-traits v0.1.40 
   Compiling gcc v0.3.51 
   Compiling approx v0.1.1 
   Compiling log v0.3.8 
   Compiling xml-rs v0.6.0 
   Compiling kernel32-sys v0.2.2 
   Compiling dbghelp-sys v0.2.0 
   Compiling shared_library v0.1.6 
   Compiling rand v0.3.15 
   Compiling num-integer v0.1.35 
   Compiling backtrace-sys v0.1.4 (https://github.com/badboy/backtrace-rs?branch=emscripten-fix#7eb1cdcd) 
   Compiling num-iter v0.1.34 
   Compiling num-complex v0.1.39 
   Compiling cgmath v0.14.1 
   Compiling num-bigint v0.1.40 
warning: `#[must_use]` on functions is experimental (see issue #43302) 
   --> /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.1.40/src/algorithms.rs:125:1 
    | 
125 | #[must_use] 
    | ^^^^^^^^^^^ 
    | 
    = help: add #![feature(fn_must_use)] to the crate attributes to enable 

warning: `#[must_use]` on methods is experimental (see issue #43302) 
   --> /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/cgmath-0.14.1/src/vector.rs:641:5 
    | 
641 |     #[must_use] 
    |     ^^^^^^^^^^^ 
    | 
    = help: add #![feature(fn_must_use)] to the crate attributes to enable 

   Compiling gl_generator v0.5.5 
   Compiling num-rational v0.1.39 
   Compiling num v0.1.40 
   Compiling cgmath v0.7.0 
warning: `#[must_use]` on methods is experimental (see issue #43302) 
   --> /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/cgmath-0.7.0/src/vector.rs:350:5 
    | 
350 |     #[must_use] 
    |     ^^^^^^^^^^^ 
    | 
    = help: add #![feature(fn_must_use)] to the crate attributes to enable 

   Compiling glutin v0.6.2 
   Compiling glium v0.15.0 
   Compiling genmesh v0.4.3 
   Compiling obj v0.5.0 
   Compiling triangle v0.0.1 (file:///n/backup_often/rust-triangle-js) 
error: could not exec the linker `emcc`: No such file or directory (os error 2) 
  | 
  = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/asmjs-u
nknown-emscripten/lib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/triangle-eac20e89b1ef072b.0.o" "-o" "/
n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/triangle-eac20e89b1ef072b.js" "-s" "EXPORTED_FUNCTIONS=[\"_main
\",\"___rdl_grow_in_place\",\"___rdl_alloc_zeroed\",\"___rdl_dealloc\",\"___rdl_shrink_in_place\",\"___rdl_alloc_excess\",\"___rdl_usable_
size\",\"___rdl_alloc\",\"___rdl_realloc_excess\",\"___rdl_realloc\",\"___rdl_oom\",\"_rust_eh_personality\"]" "/n/backup_often/rust-trian
gle-js/target/asmjs-unknown-emscripten/debug/deps/triangle-eac20e89b1ef072b.crate.allocator.o" "-O0" "--memory-init-file" "0" "-g4" "-s" "
DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps" "-L" "/n/backup_of
ten/rust-triangle-js/target/debug/deps" "-L" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/asmjs-unknown-emscri
pten/lib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libglium-b6d1a0d5932ab4c1.rlib" "/n/backup_often/ru
st-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libglutin-8526ed3cd90eeb69.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-
unknown-emscripten/debug/deps/libbacktrace-d3da2036fa2176cb.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/
deps/librustc_demangle-1bececa705e0cb49.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libwinapi-7b0da
b4b96ead755.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libdbghelp-0916cc1a48be5690.rlib" "/n/backu
p_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libbacktrace_sys-89cf001f3c0a6f06.rlib" "/n/backup_often/rust-triangle
-js/target/asmjs-unknown-emscripten/debug/deps/libshared_library-d592724e75967d0d.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unk
nown-emscripten/debug/deps/liblibc-706b6f08bfc870f6.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/lib
lazy_static-eacc57d54b86da34.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libkernel32-33f92c32b1c88e
3a.rlib" "/n/backup_often/rust-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libcfg_if-77e9c107faa2516a.rlib" "/n/backup_often/ru
st-triangle-js/target/asmjs-unknown-emscripten/debug/deps/libsmallvec-b8b27eeb9d520283.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-un
known-linux-gnu/lib/rustlib/asmjs-unknown-emscripten/lib/libstd-38880dc5defc4434.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-
linux-gnu/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc_system-021e03bbc74312ba.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unkno
wn-linux-gnu/lib/rustlib/asmjs-unknown-emscripten/lib/librand-f6905ea5d2d19bd8.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-li
nux-gnu/lib/rustlib/asmjs-unknown-emscripten/lib/libpanic_unwind-40d6296befc2e6a9.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown
-linux-gnu/lib/rustlib/asmjs-unknown-emscripten/lib/libunwind-c685a3a250f9ae49.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-li
nux-gnu/lib/rustlib/asmjs-unknown-emscripten/lib/liblibc-0d1fe84c837ffa42.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-g
nu/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc-04c9c100a697cbe8.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/l
ib/rustlib/asmjs-unknown-emscripten/lib/libstd_unicode-c967c073ed2c2954.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu
/lib/rustlib/asmjs-unknown-emscripten/lib/libcore-fca2e9d42b50e22e.rlib" "/n/HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/
rustlib/asmjs-unknown-emscripten/lib/libcompiler_builtins-d48fb5fd6549ff3e.rlib" "-l" "c" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1" 

error: aborting due to previous error 

error: Could not compile `triangle`. 

To learn more, run the command again with --verbose. 
20:17:32 eli@thoth:/n/backup_often/rust-triangle-js$ cargo update && cargo build --target=asmjs-unknown-emscripten  
    Updating registry `https://github.com/rust-lang/crates.io-index` 
    Updating git repository `https://github.com/badboy/backtrace-rs` 
    Updating git repository `https://github.com/badboy/glutin` 
      Adding conv v0.3.3 
    Updating core-foundation v0.4.1 -> v0.4.4 
    Updating core-foundation-sys v0.4.1 -> v0.4.4 
      Adding custom_derive v0.1.7 
    Updating dtoa v0.4.1 -> v0.4.2 
    Updating gcc v0.3.51 -> v0.3.53 
    Updating itoa v0.3.1 -> v0.3.3 
    Updating libc v0.2.26 -> v0.2.30 
      Adding magenta v0.1.1 
      Adding magenta-sys v0.1.1 
    Updating num-complex v0.1.39 -> v0.1.40 
    Updating rand v0.3.15 -> v0.3.16 
    Updating rustc-demangle v0.1.4 -> v0.1.5 
    Updating shared_library v0.1.6 -> v0.1.7 
    Updating x11-dl v2.14.0 -> v2.15.0 
    Updating xml-rs v0.6.0 -> v0.6.1 
warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#glutin:0.6.1 
   Compiling gcc v0.3.53 
   Compiling rustc-demangle v0.1.5 
   Compiling libc v0.2.30 
   Compiling num-complex v0.1.40 
   Compiling xml-rs v0.6.1 
   Compiling shared_library v0.1.7 
   Compiling rand v0.3.16 
   Compiling num-bigint v0.1.40 
   Compiling cgmath v0.14.1 
warning: `#[must_use]` on functions is experimental (see issue #43302) 
   --> /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.1.40/src/algorithms.rs:125:1 
    | 
125 | #[must_use] 
    | ^^^^^^^^^^^ 
    | 
    = help: add #![feature(fn_must_use)] to the crate attributes to enable 

   Compiling backtrace-sys v0.1.4 (https://github.com/badboy/backtrace-rs?branch=emscripten-fix#7eb1cdcd) 
warning: `#[must_use]` on methods is experimental (see issue #43302) 
   --> /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/cgmath-0.14.1/src/vector.rs:641:5 
    | 
641 |     #[must_use] 
    |     ^^^^^^^^^^^ 
    | 
    = help: add #![feature(fn_must_use)] to the crate attributes to enable 

   Compiling backtrace v0.2.3 (https://github.com/badboy/backtrace-rs?branch=emscripten-fix#7eb1cdcd) 
   Compiling gl_generator v0.5.5 
error[E0308]: mismatched types 
  --> /n/HOME/.cargo/git/checkouts/backtrace-rs-2d807a33d0b45dd4/7eb1cdc/src/dylib.rs:27:32 
   | 
27 |         let ptr = libc::dlopen(name.as_ptr(), libc::RTLD_LAZY); 
   |                                ^^^^^^^^^^^^^ expected i8, found u8 
   | 
   = note: expected type `*const i8` 
              found type `*const u8` 
   = help: here are some functions which might fulfill your needs: 
           - .offset(...) 
           - .wrapping_offset(...) 

error: aborting due to previous error 

error: Could not compile `backtrace`. 
warning: build failed, waiting for other jobs to finish... 
error: build failed 
20:17:54 eli@thoth:/n/backup_often/rust-triangle-js$
alexcrichton commented 7 years ago

Thanks for the report! This was unfortunately caused by https://github.com/rust-lang/libc/pull/742 where we started actually verifying the definitions of all emscripten headers, which necessitated a few breaking changes. The standard library should be updated as of https://github.com/rust-lang/rust/pull/44116 but it'll take some time for that to hit stable :(