justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Makefile.config: Move -I$(PREFIX)/include from BASE_CFLAGS to CC_LIB #483

Closed nmeum closed 2 years ago

nmeum commented 2 years ago

This is a follow up to https://github.com/justinethier/cyclone/pull/482#discussion_r758902860

The -I$(PREFIX)/include needs to be moved away from BASE_CFLAGS since, otherwise, it will be added before ~cc-extra~ and thus (partially) circumvent the changes from #482. Compare the following two Cyclone invocations with/without this commit.

Without this commit:

$ ./cyclone -d -A . -A libs -COPT '-Iinclude' -CLNK '-L.' scheme/complex.sld
gcc scheme/complex.c […] -I/usr/include -Wl,--export-dynamic -Iinclude -L/usr/lib -c

With this commit applied:

$ ./cyclone -d -A . -A libs -COPT '-Iinclude' -CLNK '-L.' scheme/complex.sld
gcc scheme/complex.c […] -Wl,--export-dynamic -Iinclude -I/usr/include -c

In #482, I originally removed the -I$(PREFIX)/include from BASE_CFLAGS entirely. However, back then I forgot to add $(COMP_INCDIRS) to CC_LIB to account for that. By doing that, this should fix the error from https://github.com/justinethier/cyclone/pull/482#discussion_r758902860 and align CC_LIB nicely with CC_PROG.

While at it, I also removed $(COMP_LIBDIRS) from CC_LIB, it shouldn't be needed since the CC_LIB command compiles object files and doesn't do any linking.

Sorry for not getting it right the first time. I hope this works without problems (:

justinethier commented 2 years ago

No worries, both fixes look good. Thanks for the follow-up!