File tree 4 files changed +43
-9
lines changed
4 files changed +43
-9
lines changed Original file line number Diff line number Diff line change 1
- import type { Component } from "solid-js" ;
1
+ import { createSignal , type Component } from "solid-js" ;
2
2
import { SetupMyTerminal } from "./xterm" ;
3
3
import type { WASIFarmRef } from "@oligami/browser_wasi_shim-threads" ;
4
4
import type { Ctx } from "./ctx" ;
@@ -22,6 +22,8 @@ const App = (props: {
22
22
} ;
23
23
let load_additional_sysroot : ( string ) => void ;
24
24
25
+ const [ triple , setTriple ] = createSignal ( "wasm32-wasip1" ) ;
26
+
25
27
return (
26
28
< >
27
29
< MonacoEditor
@@ -35,14 +37,15 @@ const App = (props: {
35
37
< SetupMyTerminal ctx = { props . ctx } callback = { props . callback } />
36
38
< div class = "flex" >
37
39
< div class = "p-4 text-white" >
38
- < RunButton />
40
+ < RunButton triple = { triple ( ) } />
39
41
</ div >
40
42
< div class = "p-4 text-white" style = { { width : "60vw" } } >
41
43
< Select
42
44
options = { triples }
43
45
class = "text-4xl text-green-700"
44
46
onChange = { ( value ) => {
45
47
console . log ( value ) ;
48
+ setTriple ( value ) ;
46
49
if ( load_additional_sysroot === undefined ) {
47
50
load_additional_sysroot = new SharedObjectRef (
48
51
props . ctx . load_additional_sysroot_id ,
Original file line number Diff line number Diff line change 1
1
import { compile_and_run , download } from "./compile_and_run" ;
2
2
3
- export const RunButton = ( ) => {
3
+ export const RunButton = ( props : {
4
+ triple : string ;
5
+ } ) => {
4
6
return (
5
7
< button
6
8
type = "button"
7
9
onClick = { ( ) => {
8
10
console . log ( "run button clicked" ) ;
9
- compile_and_run ( ) ;
11
+ compile_and_run ( props . triple ) ;
10
12
} }
11
13
class = "text-2xl text-green-700"
12
14
>
Original file line number Diff line number Diff line change @@ -35,7 +35,9 @@ export const compile_and_run_setup = (_ctx: Ctx) => {
35
35
36
36
let can_setup = false ;
37
37
38
- export const compile_and_run = async ( ) => {
38
+ export const compile_and_run = async (
39
+ triple : string ,
40
+ ) => {
39
41
if ( ! can_setup ) {
40
42
if ( await waiter . is_all_done ( ) ) {
41
43
terminal = new SharedObjectRef ( ctx . terminal_id ) . proxy < ( string ) => void > ( ) ;
@@ -58,11 +60,33 @@ export const compile_and_run = async () => {
58
60
"--sysroot" ,
59
61
"/sysroot" ,
60
62
"--target" ,
61
- "wasm32-wasip1" ,
63
+ triple ,
62
64
"--out-dir" ,
63
65
"/tmp" ,
64
66
"-Ccodegen-units=1" ,
65
67
] ;
68
+ if ( triple === "wasm32-wasip1" ) {
69
+ exec . push ( "-Clinker-flavor=wasm-ld" ) ;
70
+ exec . push ( "-Clinker=wasm-ld" ) ;
71
+ } else {
72
+ exec . push ( "-Zunstable-options" ) ;
73
+ exec . push ( "-Clinker-flavor=gnu" ) ;
74
+ exec . push ( "-Clinker=lld" ) ;
75
+ }
76
+ // const exec = [
77
+ // "rustc",
78
+ // "/main.rs",
79
+ // "--sysroot",
80
+ // "/sysroot",
81
+ // "--target",
82
+ // "x86_64-unknown-linux-musl",
83
+ // "--out-dir",
84
+ // "/linux",
85
+ // "-Zunstable-options",
86
+ // "-Clinker-flavor=gnu",
87
+ // "-Clinker=lld",
88
+ // "-Ccodegen-units=1",
89
+ // ];
66
90
await terminal ( `${ exec . join ( " " ) } \r\n` ) ;
67
91
await cmd_parser ( ...exec ) ;
68
92
while ( ! ( await waiter . is_cmd_run_end ( ) ) ) {
Original file line number Diff line number Diff line change @@ -66,9 +66,14 @@ globalThis.addEventListener("message", async (event) => {
66
66
wasi . get_share_memory ( ) . grow ( 200 ) ;
67
67
68
68
rustc_shared = new SharedObject ( ( ...args ) => {
69
- wasi . args = [ "rustc" , ...args ] ;
70
- wasi . block_start_on_thread ( ) ;
71
- console . log ( "wasi.start done" ) ;
69
+ try {
70
+ wasi . args = [ "rustc" , ...args ] ;
71
+ console . log ( "wasi.start" ) ;
72
+ wasi . block_start_on_thread ( ) ;
73
+ console . log ( "wasi.start done" ) ;
74
+ } catch ( e ) {
75
+ terminal ( e . toString ( ) ) ;
76
+ }
72
77
} , ctx . rustc_id ) ;
73
78
74
79
waiter . rustc ( ) ;
You can’t perform that action at this time.
0 commit comments