fabiensanglard / dc

Driving Compilers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

driver.php suggestions

MaskRay opened this issue · comments

clang -v -lm -std=c89 hello.c

Consider the more conventional order: clang -v -std=c89 hello.c -lm

(For libm.so, it's fine to keep -lm anywhere, but for static linking, libm.a needs to be placed the last to appease GNU ld, gold, and ld.lld --warn-backrefs)

$ clang -v -Wl,foo,bar hello.c
clang -cc1 -o hello.o hello.c
ld -o a.out hello.o foo bar

ld will receive foo bar hello.o since the positions of linker options and input files matter.

Driving a multi-file project
$ clang -v hello.c foo.c bar.c
clang -cc1 hello.c -o hello.o // Compile

Make the cc1 action -emit-obj explicit here and throughout (including other articles like cc.php)?
clang -cc1 -emit-obj hello.c -o hello.o

The default action is -fsyntax-only and -emit-obj is an important detail to keep.

$ clang foo.h -o foo.gch
$ file foo.gch
GCC precompiled header (version 013) for C

Use gcc -c foo.h -o foo.gch?

commented

Issue1: Ok, feel free to send a PR.
Issue2: (-emit-obj) I find it confusing. We already have -cc1 and -o to output an object. I don't think we need to make it more explicit.
Issue3: Not sure what you are referring to. Please specify the .php location/