Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile mooncake native-targeted libs #588

Open
1 task done
zhuguiyuan opened this issue Feb 7, 2025 · 0 comments
Open
1 task done

Cannot compile mooncake native-targeted libs #588

zhuguiyuan opened this issue Feb 7, 2025 · 0 comments

Comments

@zhuguiyuan
Copy link

zhuguiyuan commented Feb 7, 2025

Bug Report

Environment

OS

Operating System: Debian 12

MoonBit CLI Tools Version

moon 0.1.20250121 (a825806 2025-01-21) ~/.moon/bin/moon
moonc v0.1.20250121+7fc3467ab ~/.moon/bin/moonc
moonrun 0.1.20250121 (a825806 2025-01-21) ~/.moon/bin/moonrun

Steps to Reproduce

Same as the steps in this issue

moon new demo && cd demo && moon add moonbitlang/x && moon build --target native

Get:

Using cached moonbitlang/[email protected]
[================================--------] 8/10 done, 2/2 running
link-core: moonbitlang/x/fs
  cc1: fatal error: ./fs/internal/ffi/native_stub.c: No such file or directory
compilation terminated.
cc1: fatal error: ./fs/internal/ffi/native_stub.c: No such file or directory
compilation terminated.
cc1: fatal error: ./sys/internal/ffi/native_stub.c: No such file or directory
compilation terminated.
Finished. moon: ran 10 tasks, now up to date

Solving the problem by modifing .mooncakes/moonbitlang/x/fs/moon.pkg.json and .mooncakes/moonbitlang/x/sys/moon.pkg.json
(See #586)

- "cc-flags": "./fs/internal/ffi/native_stub.c"
+ "cc-flags": ".mooncakes/moonbitlang/x/fs/internal/ffi/native_stub.c"
- "cc-flags": "./sys/internal/ffi/native_stub.c"
+ "cc-flags": ".mooncakes/moonbitlang/x/sys/internal/ffi/native_stub.c"

Then compile again

moon build --target native

Get error:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Finished. moon: ran 2 tasks, now up to date

Expected Behavior

Linkage might only happens when compiling the main package.

Checklist

  • (Optional) My case is minimal enough to be reproducible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant