arnetheduck / nlvm

LLVM-based compiler for the Nim language
Other
712 stars 42 forks source link

Linking fails for wasm32 example in README #66

Open Vectornaut opened 3 months ago

Vectornaut commented 3 months ago

I'm trying to build the wasm32 example from the README, but linking fails. The error message suggests that wasm-ld isn't receiving the --no-entry flag. I'm using commit 3fbef59 of nlvm.

Reproduction

Following the read-me, I put the following files in a directory.

panicoverride.nim

proc rawoutput(s: string) = discard
proc panic(s: string) {.noreturn.} = discard

myfile.nim

proc adder*(v: int): int {.exportc.} =
  v + 4

Then I ran nlvm.

nlvm c --cpu:wasm32 --os:standalone --gc:none --passl:--no-entry myfile.nim

Even though I passed the --passl:--no-entry flag, linking failed with the message "entry symbol not defined."

Hint: used config file '[NLVM PATH]/nlvm/Nim/config/nim.cfg' [Conf]
Hint: used config file '[NLVM PATH]/nlvm/Nim/config/config.nims' [Conf]
.............................................
Hint: @["wasm-ld", "-o", "/[SOURCE PATH]/myfile.wasm", "/[HOME PATH]/.cache/nim/myfile_d/myfile.o", "--export-dynamic"] [Link]
wasm-ld: error: entry symbol not defined (pass --no-entry to suppress): _start
Error: linking failed