>
> So the help says:
>
> --debug : put debug symbols in generated binaries
>
Now, looking in src/packages/toolchain.fdoc:
method fun whatami () => "toolchain_gcc_linux (version 2)";
method fun debug_flags () =>list[string] "-g”
and for me:
method fun whatami () => "toolchain_clang_macosx (version 2)";
method fun debug_flags () => list[string] "-g”;
so lets see if it does it. There’s a nice trick:
~/felix>FLX_SHELL_ECHO=1 flx --debug --force hello.flx
…
[system] "clang++" "-fPIC" "-fvisibility=hidden" "-g" "-c" "-O1” \
"-fno-common" "-fno-strict-aliasing" "-std=c++14" "-w" "-Wfatal-errors” \
"-Wno-return-type-c-linkage" "-Wno-invalid-offsetof" "-O1" "-g” “\
-I/Users/skaller/felix/build/release/share/lib/rtl" "-I/Users/skaller/felix/build/release/host/lib/rtl" "/Users/skaller/.felix/cache/text/Users/skaller/felix/hello.cpp" -o "/Users/skaller/.felix/cache/text/Users/skaller/felix/hello_dynamic.o"
It’s a bit over eager .. the -g is in there twice!
Because:
~/felix>FLX_SHELL_ECHO=1 flx --force hello.flx
[system] "clang++" "-fPIC" "-fvisibility=hidden" "-g" "-c" "-O1”\
"-fno-common" "-fno-strict-aliasing" "-std=c++14" "-w" "-Wfatal-errors”\
"-Wno-return-type-c-linkage" "-Wno-invalid-offsetof" "-O1” \
"-I/Users/skaller/felix/build/release/share/lib/rtl" "-I/Users/skaller/felix/build/release/host/lib/rtl" "/Users/skaller/.felix/cache/text/Users/skaller/felix/hello.cpp" -o "/Users/skaller/.felix/cache/text/Users/skaller/felix/hello_dynamic.o”
Its always on :-)
Notice the —debug IS working because without —debug, the second -g flag is not
emitted. Note the confusion here:
~/felix>FLX_SHELL_ECHO=1 flx --force -O2 hello.flx
system] "clang++" "-fPIC" "-fvisibility=hidden" "-g" "-c" "-O1" "-fno-common" "-fno-strict-aliasing" "-std=c++14" "-w" "-Wfatal-errors" "-Wno-return-type-c-linkage" "-Wno-invalid-offsetof" "-O2" "-I/Users/skaller/felix/build/release/share/lib/rtl" "-I/Users/skaller/felix/build/release/host/lib/rtl" "/Users/skaller/.felix/cache/text/Users/skaller/felix/hello.cpp" -o "/Users/skaller/.felix/cache/text/Users/skaller/felix/hello_dynamic.o”
See, there is a -O1 which is standard PLUS a -O2 from the command line. That’s not really right.
The Windows toolchain also understands -O1, -O2 etc, it just translates them using
hackery. Emit debug symbols should be similar.
Note that —debug and the default are -O1 not -O2. Unfortunately a lot of
compilers can’t handle -O2. They have bugs, serious bugs, and, they also
sometimes take quadratic time, and some versions of clang the -O2 generated
code is actually slower than -O1.
—
John Skaller
ska...@internode.on.net