jimporter / bfg9000

bfg9000 - build file generator
https://jimporter.github.io/bfg9000
BSD 3-Clause "New" or "Revised" License
76 stars 21 forks source link

Default flags for certain operations #115

Closed Ipsum closed 4 years ago

Ipsum commented 5 years ago

Certain compiler flags have almost no downside and make life easier so it would be nice to have them as defaults.

jimporter commented 5 years ago

bfg already adds -fPIC to all libraries (which isn't quite the same as -fpic, but is more-compatible). There's probably some benefit to letting users control whether to use -fPIC or -fpic, but I'd have to think a bit about how to expose that.

For other "recommended" options, the bfg v0.4 way to handle this is to use toolchain files so you can use all your favorite options across all your projects. I've explicitly tried to avoid curating a list of recommended options in bfg because it opens me up to a lot of bikeshedding (e.g. which warnings should I recommend?) as well as a lot more version-wrangling (bfg can't emit an option by default if the actual compiler doesn't support it, e.g. if you're building with an old gcc).

Ipsum commented 5 years ago

Eh I think that makes sense. You might consider the sections flags though as it is really easy to build .so's that don't work without them (as in the .so builds, but when you try to link against it you get a bunch of unresolved symbols).

jimporter commented 5 years ago

One potential issue with that (I'm not sure if this would happen, but it's possible; it probably depends on how the MSVC toolchain does stuff internally) is that it results in shared libs that link ok on Linux, but fail on Windows because there doesn't appear to be an equivalent to --gc-sections for link.exe.

jimporter commented 5 years ago

Longer-term, another thing I want to do is let third parties extend bfg in interesting ways, so you could even make your own semantic option called recommended that adds all kinds of fancy options in one go. That's hopefully coming in v0.5.

Ipsum commented 5 years ago

It seems like windows does something to avoid the problem that --gc-sections solves. At least, we only had a problem on linux, not on windows.

jimporter commented 4 years ago

I'm going to close this for now, since I don't think it's necessary at the moment, but we could always revisit it in the future if this becomes a bigger issue (or we're just out of other issues to worry about!).