janet-lang / jpm

Janet Project Manager
MIT License
68 stars 22 forks source link

Allow spaces in the cc compiler bin #28

Closed greenfork closed 2 years ago

greenfork commented 2 years ago

I'm trying to use zig cc as a compiler option for jpm. I changed several things in cc.janet but here the stacktrace is not very helpful and so far I'm stuck.

I mostly replaced all (shell cc ... with (shell ;(string/split " " cc) ... in cc.janet, this is the stacktrace after that:

> jpm -l build --cc="/home/grfork/reps/zig/build/zig cc" --verbose
generating executable c source build/server.c from src/server.janet...
compiling build/server.c to build/build___server.o...
/home/grfork/reps/zig/build/zig cc -c build/server.c -std=c99 -Wall -Wextra -I/usr/local/include/janet -I/home/grfork/reps/janet-nrepl/jpm_tree/lib -O2 -o build/build___server.o
linking build/server...
/home/grfork/reps/zig/build/zig cc -std=c99 -Wall -Wextra -I/usr/local/include/janet -I/home/grfork/reps/janet-nrepl/jpm_tree/lib -O2 -o build/server build/build___server.o /usr/local/lib/libjanet.a -lm -ldl -lrt -pthread
error: @["/home/grfork/reps/zig/build/zig cc"
  "-std=c99"
  "-Wall"
  "-Wextra"
  "-I/usr/local/include/janet"
  "-I/home/grfork/reps/janet-nrepl/jpm_tree/lib"
  "-O2"
  "-o"
  "build/server"
  "build/build___server.o"
  "/usr/local/lib/libjanet.a"
  "-lm"
  "-ldl"
  "-lrt"
  "-pthread"]: No such file or directory
  in os/execute [src/core/os.c] on line 1049
  in shell [/usr/local/lib/janet/jpm/shutil.janet] (tailcall) on line 109, column 5
  in <anonymous> [/usr/local/lib/janet/jpm/rules.janet] on line 18, column 20
  in executor [/usr/local/lib/janet/jpm/rules.janet] on line 25, column 8
  in worker [/usr/local/lib/janet/jpm/dagbuild.janet] on line 65, column 23
  in <anonymous> [/usr/local/lib/janet/jpm/dagbuild.janet] on line 21, column 43
  in pmap [/usr/local/lib/janet/jpm/dagbuild.janet] on line 26, column 7
  in pdag [/usr/local/lib/janet/jpm/dagbuild.janet] (tailcall) on line 71, column 3
  in _thunk [/usr/local/bin/jpm] (tailcall) on line -1, column -1
  in cli-main [boot.janet] on line 3644, column 17
bakpakin commented 2 years ago

If you read the stacktrace, you clearly didn't replace every instance, since it is callling /home/grfork/reps/zig/build/zig cc. Otherwise, this should work fine.

greenfork commented 2 years ago

@bakpakin thanks for replying! Sure, I just don't know where else to replace so far. If I were to submit a patch, is this approach generally correct or there's a single place where we could do the splitting? This will probably be required for all the parts such as compiler, linker, archiver.

bakpakin commented 2 years ago

There may be some call sites in declare.janet for generating a static executable, but there aren't many places to check through.

There is also the simpler option of wrapping zig cc in a script zigcc which then just calls exec.