moon icon indicating copy to clipboard operation
moon copied to clipboard

[RR] `MOON_CC` does not support passing parameters

Open bikallem opened this issue 7 months ago • 5 comments

Bug Report

Environment

OS

Operating System: ArchLinux

MoonBit CLI Tools Version

moon 0.1.20251013 (e9f94ea 2025-10-13) ~/.moon/bin/moon
moonc v0.6.29+5ba65ac74 (2025-10-13) ~/.moon/bin/moonc
moonrun 0.1.20251013 (e9f94ea 2025-10-13) ~/.moon/bin/moonrun
moon-pilot 0.0.1-81125f2 (2025-10-13) ~/.moon/bin/moon-pilot

Steps to Reproduce

Expected Behavior

Compilation succeeds as per normal

Actual Behavior

Attempting build with NEW_MOON=1 results in error. This works okay without NEW_MOON=1 or with NEW_MOON=0

NEW_MOON=1 MOON_CC="clang -g -O1 -fno-omit-frame-pointer" moon build

results in

failed: 'clang -g -O1 -fno-omit-frame-pointer' -o /home/user1/projects/mariadb.mbt/target/native/release/build/.mooncakes/moonbitlang/x/sys/internal/ffi/native_stub.o -I/home/user1/.moon/include -c -fwrapv -fno-strict-aliasing -O2 /home/user1/projects/mariadb.mbt/.mooncakes/moonbitlang/x/sys/internal/ffi/native_stub.c
/bin/sh: line 1: clang -g -O1 -fno-omit-frame-pointer: command not found
Failed with 0 warnings, 0 errors.
error: failed when building project

Checklist

  • [x] (Optional) My case is minimal enough to be reproducible.

bikallem avatar Oct 14 '25 20:10 bikallem

Caused by not shell-splitting the MOON_CC before using. Will review.

lynzrand avatar Oct 15 '25 08:10 lynzrand

After a review of the current logic, your usage is currently not an intended usage, because MOON_CC is expected to be just a path (and we use path operations on it). Although I would equally love to feed things like zig cc -target blahblahblah into MOON_CC and call it a day, this is currently not supported.

Currently, you can set the C compiler flags in moon.pkg.json's $.link.native.cc_flags field to achieve similar effects. We will re-review this when we have time.

lynzrand avatar Oct 17 '25 03:10 lynzrand

As said in https://github.com/moonbitlang/moon/issues/1101#issuecomment-3447980016, I think we can proceed fixing with shell-split MOON_CC before passing it to other parts.

lynzrand avatar Oct 26 '25 03:10 lynzrand

Thanks for the update.

Here is my particular use case. I am working on moonbit bindings to mariadb/mysql (https://github.com/bikallem/mariadb.mbt). It is quite useful to be able to determine if there are any memory leaks/issues with the bindings that I have created. As such I am using asan/valgrind.

I think we can proceed fixing with shell-split MOON_CC before passing it to other parts.

MOON_CC currently works with default build system(not RR). Do you mean to add this support to RR?

bikallem avatar Oct 26 '25 09:10 bikallem

Yes. Legacy works because it used simple string concatenation, which... Let's just say it's error-prone for a use case like this. I will try to proceed with shell-splitting the next workday.

lynzrand avatar Oct 26 '25 10:10 lynzrand