servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 117 forks source link

OSX build failed #472

Closed caracal7 closed 5 years ago

caracal7 commented 5 years ago

OSX 10.13.16 High Sierra

Cargo.toml

[package]
name = "mozjs-test"
version = "0.1.0"
edition = "2018"

[dependencies]

mozjs = { git = "https://github.com/servo/rust-mozjs" }
libc = "0.2"

main.rs

extern crate mozjs;

use mozjs::rust::{JSEngine};

fn main() {
    println!("Hello, moz-js!");
    let _engine = JSEngine::init().unwrap();
}

result

   Compiling mozjs-test v0.1.0 (/Users/caracal/Desktop/mozjs-test)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.25dhedcbqi6zv9mj.rcgu.o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.2q13vmslzls2yo1j.rcgu.o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.3e69aaxj2129ngyf.rcgu.o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.45hn0jzy9nuf4jmi.rcgu.o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.4tewz2sgwqxgxony.rcgu.o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.tdy6k5u1q8wy1ro.rcgu.o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.vkj1wgbdxc99322.rcgu.o" "-o" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/mozjs_test-3a85ee594fb1ad64.4pa2tiillh501viw.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/caracal/Desktop/mozjs-test/target/debug/deps" "-L" "/Users/caracal/Desktop/mozjs-test/target/debug/build/mozjs-e62261bd548d3266/out" "-L" "/Users/caracal/Desktop/mozjs-test/target/debug/build/mozjs_sys-e9300a40c0ac0408/out/js/src/build" "-L" "/Users/caracal/Desktop/mozjs-test/target/debug/build/mozjs_sys-e9300a40c0ac0408/out" "-L" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/libmozjs-9c51db2bbc168715.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/libnum_traits-15a8f2e25739994c.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/libmozjs_sys-88d41f946458d233.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/liblibz_sys-7cd5cc47914718d4.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/liblog-852601a2e97ed777.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/libcfg_if-221f2de429608e0c.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/liblibc-77809da99969893b.rlib" "/Users/caracal/Desktop/mozjs-test/target/debug/deps/liblazy_static-c39df29342607025.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-dd92597dd9e457eb.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-b72bbfc859438b00.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-5304f153064505ef.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-5b7dc2df9573122e.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-2f4dbf07853bb22c.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-c7914cfe4287e33c.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-3af362d83b0b5513.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-6fbbb5234e844b27.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-54876c46719250d5.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-c279dcaed2c4f360.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-c7e5e9704757ec18.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-b8a3e9859b79f030.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-81063d87466df8b1.rlib" "/Users/caracal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-a7ff03a2d412da61.rlib" "-lc++" "-lc++" "-lz" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: Undefined symbols for architecture x86_64:
            "_icudt63_dat", referenced from:
                openCommonData(char const*, int, UErrorCode*) in libmozjs_sys-88d41f946458d233.rlib(udata.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 `mozjs-test`.

To learn more, run the command again with --verbose.
[Finished running. Exit status: 101]
jdm commented 5 years ago

I'm not sure exactly why it's not working, but if you use an override for mozjs_sys and add --disable-icu to https://github.com/servo/mozjs/blob/master/makefile.cargo#L6 then it should build.

caracal7 commented 5 years ago

I have Unknown option: --disable-icu

--- stderr
Traceback (most recent call last):
  File "/Users/caracal/Desktop/mozjs-test/vendors/mozjs/mozjs/js/src/../../configure.py", line 132, in <module>
    sys.exit(main(sys.argv))
  File "/Users/caracal/Desktop/mozjs-test/vendors/mozjs/mozjs/js/src/../../configure.py", line 38, in main
    sandbox.run(os.path.join(os.path.dirname(__file__), 'moz.configure'))
  File "/Users/caracal/Desktop/mozjs-test/vendors/mozjs/mozjs/python/mozbuild/mozbuild/configure/__init__.py", line 477, in run
    raise InvalidOptionError(msg)
mozbuild.configure.options.InvalidOptionError: Unknown option: --disable-icu
make: *** [maybe-configure] Error 1
thread 'main' panicked at 'assertion failed: result.success()', vendors/mozjs/build.rs:111:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

mozjs/makefile.cargo

# Default flags
CONFIGURE_FLAGS := \
    --disable-icu \
    --disable-jemalloc \
    --disable-js-shell \
    --disable-tests \
    --disable-shared-js \
    --build-backends=RecursiveMake \
        --enable-posix-nspr-emulation

...
jdm commented 5 years ago

Ah, sorry, try --disable-intl.

caracal7 commented 5 years ago

Anyway 🤗


    raise InvalidOptionError(msg)
mozbuild.configure.options.InvalidOptionError: Unknown option: --disable-intl
make: *** [maybe-configure] Error 1
thread 'main' panicked at 'assertion failed: result.success()', vendors/mozjs/build.rs:111:5 ```
jdm commented 5 years ago

Ok, so it turns out I was thinking of --without-intl-api (https://github.com/servo/mozjs/blob/99952b4e799a9b2d7647176d6f2d94d78e642b7e/makefile.cargo#L21).

caracal7 commented 5 years ago

Everything is working Thanks a lot)