Chakracore: [OS X] ChakraCore is built against different SDK than Rust which prevents linking ChakraCore into Rust projects

Created on 25 Aug 2016  路  11Comments  路  Source: chakra-core/ChakraCore

Build Bug Compatibility OSX

Most helpful comment

I will try to have my build script up to date, but right now it is automated and works on Windows, macOS & Linux (all tested on x64 static & dynamic).
Besides linking it also generates an interface file of the entire API usable in Rust.

For any rustaceans interested: https://github.com/darfink/chakracore-rs/tree/master/chakracore-sys
It will be published on Crates.io this week.

All 11 comments

1493 should take care of this.

@Fishrock123 Can you confirm whether this issue was fixed for you by #1493 ?

Closing this one for now. From the discussion at #1493 there should be other things to consider (no longer SDK difference)

@Fishrock123 once you can share the steps, please open up an issue with the details so we may look into. Thanks!

Prepared the bash script below for anyone looking into calling ChakraCore from Rust

CHAKRA_BUILD_FOLDER=$1

if [ ! -d $CHAKRA_BUILD_FOLDER ]; then
  echo "usage: compile.sh <path to ChakraCore BuildLinux folder>"
  exit 0
fi

# UPDATE THIS to Rustlib path on your system
# !!! You should also update a4729905
RUSTLIBS="/usr/local/Cellar/rust/1.13.0/lib/rustlib/x86_64-apple-darwin/lib"

cc -m64 -L $RUSTLIBS helloWorld.0.o -o helloWorld -Wl,-dead_strip \
-nodefaultlibs -L $RUSTLIBS \
 $RUSTLIBS/libstd-a4729905.rlib \
 $RUSTLIBS/libpanic_unwind-a4729905.rlib \
 $RUSTLIBS/libunwind-a4729905.rlib \
 $RUSTLIBS/librand-a4729905.rlib \
 $RUSTLIBS/libcollections-a4729905.rlib \
 $RUSTLIBS/librustc_unicode-a4729905.rlib \
 $RUSTLIBS/liballoc-a4729905.rlib \
 $RUSTLIBS/liballoc_jemalloc-a4729905.rlib \
 $RUSTLIBS/liblibc-a4729905.rlib \
 $RUSTLIBS/libcore-a4729905.rlib \
 $RUSTLIBS/libcompiler_builtins-a4729905.rlib \
 -Wl,-force_load \
 $CHAKRA_BUILD_FOLDER/pal/src/libChakra.Pal.a \
 $CHAKRA_BUILD_FOLDER/lib/Common/Core/libChakra.Common.Core.a \
 $CHAKRA_BUILD_FOLDER/lib/Jsrt/libChakra.Jsrt.a \
 /usr/local/opt/icu4c/lib/libicudata.a \
 /usr/local/opt/icu4c/lib/libicuuc.a \
 /usr/local/opt/icu4c/lib/libicui18n.a \
 -framework CoreFoundation -framework Security \
 -lm -ldl -Wno-c++11-compat-deprecated-writable-strings \
 -Wno-deprecated-declarations -Wno-unknown-warning-option \
 -l System -l pthread -l c -l m -lstdc++ -std=c++11

@obastemur Still trying to get around to this again... some day.

How is this script intended to be used?

@Fishrock123 Compile the rust file i.e. HelloWorld.rs into helloWorld.o and run the script above. It will link all of them into a single binary.

@obastemur @liminzhu Is there any place for a script like that in the wiki, samples, or other documentation, so it doesn't just get lost in this issue?

@dilijev unless we don't put a working rust sample and keep track of it, I don't think it is a good idea to locate such script to our wiki or any other official document.

Sample script above, I just wanted to clear out couple of tricky steps for people interested using ChakraCore from Rust. Search engines should lead to this page whenever they need it.

@obastemur fair enough. Anything we can do to make this easier to find for people looking for this? I guess searching our issues for "Rust" is enough.

I will try to have my build script up to date, but right now it is automated and works on Windows, macOS & Linux (all tested on x64 static & dynamic).
Besides linking it also generates an interface file of the entire API usable in Rust.

For any rustaceans interested: https://github.com/darfink/chakracore-rs/tree/master/chakracore-sys
It will be published on Crates.io this week.

@darfink I haven't tested but sounds really good! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tommyZZM picture tommyZZM  路  4Comments

jdalton picture jdalton  路  4Comments

atefshehata picture atefshehata  路  3Comments

obastemur picture obastemur  路  4Comments

gustavopinto picture gustavopinto  路  3Comments