diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index 09bcef755e..5653088380 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -37,29 +37,12 @@ fn link_linux( .args(&[ "-arch", arch_str(target), - "/usr/lib/x86_64-linux-gnu/crti.o", - "/usr/lib/x86_64-linux-gnu/crtn.o", - "/usr/lib/x86_64-linux-gnu/Scrt1.o", - "-dynamic-linker", - "/lib64/ld-linux-x86-64.so.2", + // Inputs + dest_filename.to_str().unwrap(), // app.o + host_input_path.to_str().unwrap(), // host.o // Output "-o", binary_path.to_str().unwrap(), // app - // Inputs - host_input_path.to_str().unwrap(), // host.o - dest_filename.to_str().unwrap(), // app.o - // Libraries - see https://github.com/rtfeldman/roc/pull/554#discussion_r496365925 - // for discussion and further references - "-lc", - "-lm", - "-lpthread", - "-ldl", - "-lrt", - "-lutil", - "-lc_nonshared", - "-lc++", - "-lunwind", - // "-lgcc", // TODO will eventually need compiler_rt from gcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840 ]) .spawn() } diff --git a/examples/quicksort/platform/host/README.md b/examples/quicksort/platform/README.md similarity index 100% rename from examples/quicksort/platform/host/README.md rename to examples/quicksort/platform/README.md diff --git a/examples/quicksort/platform/build-linux.sh b/examples/quicksort/platform/build-linux.sh new file mode 100755 index 0000000000..e30a9f17c1 --- /dev/null +++ b/examples/quicksort/platform/build-linux.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +clang -c host.c -o c_host.o +rustc host.rs -o rust_host.o + +# Linking - see https://github.com/rtfeldman/roc/pull/554#discussion_r496365925 +# for discussion and further references +# +# TODO will eventually need compiler_rt from -lgcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840 +ld -r -static \ + -L /usr/lib/x86_64-linux-musl \ + -L /usr/lib/llvm-10/lib \ + -L /usr/lib/x86_64-linux-gnu \ + -dynamic-linker /lib64/ld-linux-x86-64.so.2 \ + /usr/lib/x86_64-linux-gnu/crti.o \ + /usr/lib/x86_64-linux-gnu/crtn.o \ + /usr/lib/x86_64-linux-gnu/Scrt1.o \ + -lc \ + -lm \ + -lpthread \ + -ldl \ + -lrt \ + -lutil \ + -lc++abi \ + -lunwind \ + c_host.o \ + rust_host.o \ + -o host.o + +rm -f c_host.o +rm -f rust_host.o diff --git a/examples/quicksort/platform/build.sh b/examples/quicksort/platform/build.sh deleted file mode 100755 index 111e367e69..0000000000 --- a/examples/quicksort/platform/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -clang -c host/src/host.c -o c_host.o -rustc host/src/host.rs -o rust_host.o -ld -r c_host.o rust_host.o -o host.o - -rm -f c_host.o -rm -f rust_host.o diff --git a/examples/quicksort/platform/host/src/host.c b/examples/quicksort/platform/host.c similarity index 100% rename from examples/quicksort/platform/host/src/host.c rename to examples/quicksort/platform/host.c diff --git a/examples/quicksort/platform/host/src/host.rs b/examples/quicksort/platform/host.rs similarity index 100% rename from examples/quicksort/platform/host/src/host.rs rename to examples/quicksort/platform/host.rs