WebAssembly / wasi-libc

WASI libc implementation for WebAssembly
https://wasi.dev
Other
861 stars 203 forks source link

Cannot build with alternative `WASM_CFLAGS` #259

Open alexcrichton opened 3 years ago

alexcrichton commented 3 years ago

I've been toying around with debugging a wasm module and was trying to enable some of the debugging features of dlmalloc.c, but altering WASM_CFLAGS seems to cause wasi-libc to fail to build:

$ WASM_CFLAGS=-O0 make
...
# Check that the computed metadata matches the expected metadata.
# This ignores whitespace because on Windows the output has CRLF line endings.
diff -wur "/home/acrichto/code/wasi-libc/expected/wasm32-wasi" "/home/acrichto/code/wasi-libc/sysroot/share/wasm32-wasi"
diff -wur /home/acrichto/code/wasi-libc/expected/wasm32-wasi/predefined-macros.txt /home/acrichto/code/wasi-libc/sysroot/share/wasm32-wasi/predefined-macros.txt
--- /home/acrichto/code/wasi-libc/expected/wasm32-wasi/predefined-macros.txt    2021-07-15 07:41:30.856269710 -0700
+++ /home/acrichto/code/wasi-libc/sysroot/share/wasm32-wasi/predefined-macros.txt       2021-10-01 11:26:28.282342331 -0700
@@ -1118,7 +1118,6 @@
 #define NAN (0.0f/0.0f)
 #define NBBY 8
 #define NCARGS 131072
-#define NDEBUG 1
 #define ND_NA_FLAG_OVERRIDE 0x00000020
 #define ND_NA_FLAG_ROUTER 0x00000080
 #define ND_NA_FLAG_SOLICITED 0x00000040
@@ -2641,13 +2640,13 @@
 #define __NEED_wchar_t
 #define __NEED_wctype_t
 #define __NEED_wint_t
+#define __NO_INLINE__ 1
 #define __OBJC_BOOL_IS_BOOL 0
 #define __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES 3
 #define __OPENCL_MEMORY_SCOPE_DEVICE 2
 #define __OPENCL_MEMORY_SCOPE_SUB_GROUP 4
 #define __OPENCL_MEMORY_SCOPE_WORK_GROUP 1
 #define __OPENCL_MEMORY_SCOPE_WORK_ITEM 0
-#define __OPTIMIZE__ 1
 #define __ORDER_BIG_ENDIAN__ 4321
 #define __ORDER_LITTLE_ENDIAN__ 1234
 #define __ORDER_PDP_ENDIAN__ 3412
@@ -3102,7 +3101,7 @@
 #define and_eq &=
 #define asin(x) __tg_real_complex(asin, (x))
 #define asinh(x) __tg_real_complex(asinh, (x))
-#define assert(x) (void)0
+#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
 #define atan(x) __tg_real_complex(atan, (x))
 #define atan2(x,y) __tg_real_2(atan2, (x), (y))
 #define atanh(x) __tg_real_complex(atanh, (x))
make: *** [Makefile:513: check-symbols] Error 1

Could the check-symbols target get relegated to CI and not be part of the main build perhaps?

sbc100 commented 3 years ago

Yes, perhaps that is good idea. At least there needs to be an easy way to disable it .. its also fragile in the face of changing llvm versions.

hunjixin commented 2 years ago

how is WASM_FLAGS work, i cannot found any code about WASM_FLAGS

sbc100 commented 2 years ago

These days its called EXTRA_CFLAGS I believe: https://github.com/WebAssembly/wasi-libc/blob/main/Makefile#L11