I’m attempting to implement a new clang front end option for my project (-fmyopt=blah), and have made the changes required that I can access and act on it in my Target class when compiling. When linking, it causes a bit of trouble, as clang passes it on to gcc in the link phase:
What part of the code is the link command line constructed in, and what is the mechanism used to select which options get passed to other stages (or an example of that)?
The linker command line would be constructed in the driver (clang/lib/Driver/…) and exactly where the code is depends on your triple. You could grep for ‘Linker::ConstructJob’ and see what looks most likely, or try stepping through the driver in a debugger to see which one is invoked. I am a little surprised that arbitrary –f options would be passed through in the link phase.
That’s very odd, because other options that are defined in similar ways (e.g. –fparse-all-comments) do not get forwarded to the linker. Comparing how your option behaves relative to other similar options might help diagnose the problem.