Skip to content

Commit ff0ed3e

Browse files
committed
Merge branch 'master' of https://github.com/Others/silverfish
2 parents 8e96818 + 039bd18 commit ff0ed3e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ FLAGS:
1919
2020
OPTIONS:
2121
-o, --output <output> Output bc file
22+
--target <target> Set compilation target
2223
2324
ARGS:
2425
<input> Input wasm file
25-
2626
```
2727

2828
# Installation from Source
@@ -46,7 +46,6 @@ sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$LLVM_VER
4646
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-$LLVM_VERSION 100
4747
```
4848
4. [Install the C++ Standard Library for LLVM](https://libcxx.llvm.org/)
49-
5049
5. Clone and build silverfish
5150
```sh
5251
git clone https://github.com/gwsystems/silverfish.git

src/codegen/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ pub fn process_to_llvm(
5353
let llvm_ctx = &*LLVMCtx::new();
5454
let llvm_module = &*LLVMModule::new(&wasm_module.source_name, llvm_ctx);
5555

56-
// Setup to compile to the local target
57-
// FIXME: Should be able to use the local default target, but that doesn't work properly on OSX
58-
llvm_module.set_target("x86_64-apple-macosx10.15.0");
59-
// llvm_module.set_target("thumbv7m-none-unknown-eabi");
60-
// llvm_module.set_target("i686-pc-linux-gnu");
56+
// Accept --target to compile for specific target, otherwise omit target
57+
// triple from bytecode, this defaults to the host target in LLVM
58+
if let Some(ref target) = opt.target {
59+
llvm_module.set_target(target);
60+
} else {
61+
// INFO: Target overrides for development:
62+
// llvm_module.set_target("x86_64-apple-macosx10.15.0");
63+
// llvm_module.set_target("thumbv7m-none-unknown-eabi");
64+
// llvm_module.set_target("i686-pc-linux-gnu");
65+
}
6166

6267
// Remap WASM generated names to exported names
6368
for e in wasm_module.exports {

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ pub struct Opt {
4242
/// Don't generate native globals, let the runtime handle it
4343
#[structopt(long = "runtime-globals")]
4444
use_runtime_global_handling: bool,
45+
46+
/// Set compilation target
47+
#[structopt(long = "target")]
48+
target: Option<String>,
4549
}
4650

4751
fn main() -> io::Result<()> {

0 commit comments

Comments
 (0)