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

prepro is $(CPP) not $(CC) -E #4870

Closed
wants to merge 1 commit into from
Closed

prepro is $(CPP) not $(CC) -E #4870

wants to merge 1 commit into from

Conversation

pmp-p
Copy link
Contributor

@pmp-p pmp-p commented Jun 24, 2019

see Line 75 and most Makefile eg

@pmp-p
Copy link
Contributor Author

pmp-p commented Jun 24, 2019

could be usefull also to have constantly preprocessor defines -D__CPP__ since preprocessor can choke on cross compiler special includes like emscripten.h on javascript port when building modules.

@dpgeorge
Copy link
Member

I would be slightly wary of this (especially since py/mkenv.mk doesn't define CPP in terms of CROSS_COMPILE), but actually auto qstr generation already passes $(CFLAGS) directly to $(CPP) so it must work fine.

Merged in 862cc45

@dpgeorge dpgeorge closed this Jun 25, 2019
@pmp-p
Copy link
Contributor Author

pmp-p commented Jun 25, 2019

i was tring new build system for modules for official javascript port, javascript port Makefile does does define CROSS=0 and does not mention CROSS_COMPILE. also $(CC) should use emcc

https://emscripten.org/docs/tools_reference/emcc.html also not hacks like

CPP += -isystem $(EMSCRIPTEN)/system/include/libc -cxx-isystem $(EMSCRIPTEN)/system/include/libcxx

emcc -E as in actually $(CC) -E is not a valid preprocessor.

some compilers defines variables that are unknown to preprocessors but user are expected to use them eg __EMSCRIPTEN__ || __ANDROID__ , prepro does not signal itself and does not get them from CFLAGS because of system include.

i'm not a C expert but even for a hobby i find that a bit messy.

@pmp-p
Copy link
Contributor Author

pmp-p commented Jun 25, 2019

@dpgeorge i get your point but I can't find a way to launch preprocessor via emcc in emscripten doc

i guess there's no other way than using raw emscripten clang and i still wonder how to handle eg "-s USE_SDL=2" or such CFLAGS parameters which forces inclusion of port specific versions that a module could require.

javascript $ emmake make V=1 CFLAGS_EXTRA="-DMODULE_EXAMPLE_ENABLED=1 -s USE_SDL=2" USER_C_MODULES=cmod
Including User C Module from cmod/example
mkdir -p build/genhdr
python3 ../../py/makeversionhdr.py build/genhdr/mpversion.h
GEN build/genhdr/mpversion.h
GEN build/genhdr/moduledefs.h
python3 ../../py/makemoduledefs.py --vpath="., ../.., cmod" example/example.c py/mpstate.c py/malloc.c py/gc.c py/pystack.c py/qstr.c py/vstr.c py/mpprint.c py/unicode.c py/mpz.c py/reader.c py/lexer.c py/parse.c py/scope.c py/compile.c py/emitcommon.c py/emitbc.c py/asmbase.c py/asmx64.c py/emitnx64.c py/asmx86.c py/emitnx86.c py/asmthumb.c py/emitnthumb.c py/emitinlinethumb.c py/asmarm.c py/emitnarm.c py/asmxtensa.c py/emitnxtensa.c py/emitinlinextensa.c py/formatfloat.c py/parsenumbase.c py/parsenum.c py/emitglue.c py/persistentcode.c py/runtime.c py/runtime_utils.c py/scheduler.c py/nativeglue.c py/stackctrl.c py/argcheck.c py/warning.c py/map.c py/obj.c py/objarray.c py/objattrtuple.c py/objbool.c py/objboundmeth.c py/objcell.c py/objclosure.c py/objcomplex.c py/objdeque.c py/objdict.c py/objenumerate.c py/objexcept.c py/objfilter.c py/objfloat.c py/objfun.c py/objgenerator.c py/objgetitemiter.c py/objint.c py/objint_longlong.c py/objint_mpz.c py/objlist.c py/objmap.c py/objmodule.c py/objobject.c py/objpolyiter.c py/objproperty.c py/objnone.c py/objnamedtuple.c py/objrange.c py/objreversed.c py/objset.c py/objsingleton.c py/objslice.c py/objstr.c py/objstrunicode.c py/objstringio.c py/objtuple.c py/objtype.c py/objzip.c py/opmethods.c py/sequence.c py/stream.c py/binary.c py/builtinimport.c py/builtinevex.c py/builtinhelp.c py/modarray.c py/modbuiltins.c py/modcollections.c py/modgc.c py/modio.c py/modmath.c py/modcmath.c py/modmicropython.c py/modstruct.c py/modsys.c py/moduerrno.c py/modthread.c py/vm.c py/bc.c py/showbc.c py/repl.c py/smallint.c py/frozenmod.c extmod/moductypes.c extmod/modujson.c extmod/modure.c extmod/moduzlib.c extmod/moduheapq.c extmod/modutimeq.c extmod/moduhashlib.c extmod/moducryptolib.c extmod/modubinascii.c extmod/virtpin.c extmod/machine_mem.c extmod/machine_pinbase.c extmod/machine_signal.c extmod/machine_pulse.c extmod/machine_i2c.c extmod/machine_spi.c extmod/modussl_axtls.c extmod/modussl_mbedtls.c extmod/modurandom.c extmod/moduselect.c extmod/moduwebsocket.c extmod/modwebrepl.c extmod/modframebuf.c extmod/vfs.c extmod/vfs_reader.c extmod/vfs_posix.c extmod/vfs_posix_file.c extmod/vfs_fat.c extmod/vfs_fat_diskio.c extmod/vfs_fat_file.c extmod/utime_mphal.c extmod/uos_dupterm.c lib/embed/abort_.c lib/utils/printf.c build/genhdr/moduledefs.h main.c mphalport.c modutime.c  > build/genhdr/moduledefs.h
GEN build/genhdr/qstr.i.last
clang -E -isystem /opt/sdk/emsdk/fastcomp/emscripten/system/include/libc -cxx-isystem /opt/sdk/emsdk/fastcomp/emscripten/system/include/libcxx -DNO_QSTR -Ibuild/tmp -m32 -Wall -Werror -I. -I../.. -Ibuild -std=c99  -O0 -DNDEBUG -fdata-sections -ffunction-sections cmod/example/example.c ../../py/mpstate.c ../../py/malloc.c ../../py/gc.c ../../py/pystack.c ../../py/qstr.c ../../py/vstr.c ../../py/mpprint.c ../../py/unicode.c ../../py/mpz.c ../../py/reader.c ../../py/lexer.c ../../py/parse.c ../../py/scope.c ../../py/compile.c ../../py/emitcommon.c ../../py/emitbc.c ../../py/asmbase.c ../../py/asmx64.c ../../py/emitnx64.c ../../py/asmx86.c ../../py/emitnx86.c ../../py/asmthumb.c ../../py/emitnthumb.c ../../py/emitinlinethumb.c ../../py/asmarm.c ../../py/emitnarm.c ../../py/asmxtensa.c ../../py/emitnxtensa.c ../../py/emitinlinextensa.c ../../py/formatfloat.c ../../py/parsenumbase.c ../../py/parsenum.c ../../py/emitglue.c ../../py/persistentcode.c ../../py/runtime.c ../../py/runtime_utils.c ../../py/scheduler.c ../../py/nativeglue.c ../../py/stackctrl.c ../../py/argcheck.c ../../py/warning.c ../../py/map.c ../../py/obj.c ../../py/objarray.c ../../py/objattrtuple.c ../../py/objbool.c ../../py/objboundmeth.c ../../py/objcell.c ../../py/objclosure.c ../../py/objcomplex.c ../../py/objdeque.c ../../py/objdict.c ../../py/objenumerate.c ../../py/objexcept.c ../../py/objfilter.c ../../py/objfloat.c ../../py/objfun.c ../../py/objgenerator.c ../../py/objgetitemiter.c ../../py/objint.c ../../py/objint_longlong.c ../../py/objint_mpz.c ../../py/objlist.c ../../py/objmap.c ../../py/objmodule.c ../../py/objobject.c ../../py/objpolyiter.c ../../py/objproperty.c ../../py/objnone.c ../../py/objnamedtuple.c ../../py/objrange.c ../../py/objreversed.c ../../py/objset.c ../../py/objsingleton.c ../../py/objslice.c ../../py/objstr.c ../../py/objstrunicode.c ../../py/objstringio.c ../../py/objtuple.c ../../py/objtype.c ../../py/objzip.c ../../py/opmethods.c ../../py/sequence.c ../../py/stream.c ../../py/binary.c ../../py/builtinimport.c ../../py/builtinevex.c ../../py/builtinhelp.c ../../py/modarray.c ../../py/modbuiltins.c ../../py/modcollections.c ../../py/modgc.c ../../py/modio.c ../../py/modmath.c ../../py/modcmath.c ../../py/modmicropython.c ../../py/modstruct.c ../../py/modsys.c ../../py/moduerrno.c ../../py/modthread.c ../../py/vm.c ../../py/bc.c ../../py/showbc.c ../../py/repl.c ../../py/smallint.c ../../py/frozenmod.c ../../extmod/moductypes.c ../../extmod/modujson.c ../../extmod/modure.c ../../extmod/moduzlib.c ../../extmod/moduheapq.c ../../extmod/modutimeq.c ../../extmod/moduhashlib.c ../../extmod/moducryptolib.c ../../extmod/modubinascii.c ../../extmod/virtpin.c ../../extmod/machine_mem.c ../../extmod/machine_pinbase.c ../../extmod/machine_signal.c ../../extmod/machine_pulse.c ../../extmod/machine_i2c.c ../../extmod/machine_spi.c ../../extmod/modussl_axtls.c ../../extmod/modussl_mbedtls.c ../../extmod/modurandom.c ../../extmod/moduselect.c ../../extmod/moduwebsocket.c ../../extmod/modwebrepl.c ../../extmod/modframebuf.c ../../extmod/vfs.c ../../extmod/vfs_reader.c ../../extmod/vfs_posix.c ../../extmod/vfs_posix_file.c ../../extmod/vfs_fat.c ../../extmod/vfs_fat_diskio.c ../../extmod/vfs_fat_file.c ../../extmod/utime_mphal.c ../../extmod/uos_dupterm.c ../../lib/embed/abort_.c ../../lib/utils/printf.c build/genhdr/moduledefs.h main.c mphalport.c modutime.c ../../py/mpconfig.h mpconfigport.h >build/genhdr/qstr.i.last
cmod/example/example.c:8:10: fatal error: 'SDL2/SDL.h' file not found
#include "SDL2/SDL.h"
1 error generated.
../../py/mkrules.mk:74: recipe for target 'build/genhdr/qstr.i.last' failed
make: *** [build/genhdr/qstr.i.last] Error 1
make: *** Deleting file 'build/genhdr/qstr.i.last'

is not that a flaw in emscripten ( not accepting -E and giving proper path to clang ) ?

@pmp-p pmp-p deleted the patch-6 branch June 25, 2019 10:10
@pmp-p
Copy link
Contributor Author

pmp-p commented Jun 25, 2019

it seems all libraries includes ends up in various $(EM_CACHE)/asmjs/ports-builds/*/include
looks a bit hard to inform preprocessor of those without integrating some emcc code

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Jun 23, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants