Emitting PDB files during compilation

4 views
Skip to first unread message

Garrett Bluma

unread,
Mar 8, 2020, 3:39:39 PM3/8/20
to felix-l...@googlegroups.com
For debugging purposes, I'd like to have felix emit .pdb files (debugging symbols) in Windows. This can be done by including the /Zi command line flag to cl.exe.

I've been able to hack this into the compiler by directly editing

    share/lib/std/felix/toolchain/msvc_win.flx

to include the flag everywhere, but this should be something that's able to be passed using the --debug argument.

    flx --debug myfile.flx

So my question is this, is there an existing way to propagate that option down to the toolchain? Has this been covered by gcc or another tool?

P.S. I guess I'm back from the long hiatus.

John Skaller2

unread,
Mar 8, 2020, 7:58:04 PM3/8/20
to felix google
So the help says:

--debug : put debug symbols in generated binaries

although I don’t know if it works. On Mac the debug symbols live in a separate file.
I have a suspicion Windows does that too. But still, the debug symbols should be emitted!
If the toolchain isn’t doing that as a result of the —debug switch its a bug.




John Skaller
ska...@internode.on.net





John Skaller2

unread,
Mar 8, 2020, 8:37:57 PM3/8/20
to felix google
>
> 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





Reply all
Reply to author
Forward
0 new messages