News for hackers. Stuff that matters.
Re:0+0 > 0: C++ thread-local storage performance by yosefk on Monday February 17, 2025 @01:51PM (#43082073)
Thanks for you kind words!

I don't think build systems add -fPIC automatically, nor remove it automatically. C++ build systems do not stoop to the question of how to best build a C++ program, by and large. They are more task graph executors - either bad ones, like make, or good ones, like Bazel, but mostly task graph executors; the most "C++ support" you will get is native support for scanning #include files (as opposed to doing it yourself like make forces you to.)

Re:0+0 > 0: C++ thread-local storage performance by gavinhoward on Monday February 17, 2025 @02:00PM (#43082173)
Makes sense.

I want to build a "standard library" for my build system that would stoop to that. I can do that because my build system is not just a task graph executor; it is backed by a full programming language and can add its own libraries to that language. IOW, I can add a `cpp` package to the build system that implements support for how to best build a C++ program.

So if you have a wishlist for that support, I'd love to hear it.

Re:0+0 > 0: C++ thread-local storage performance by smeenai on Monday February 17, 2025 @05:04PM (#43083731)
Idk about Bazel, but Buck2 (and Buck1, but 2 is better in every way) does handle adding -fPIC for shared libraries and leaving it off when statically linking. Each library has a PIC and non-PIC version, and the appropriate one is selected depending on if the library is being linked into an executable or a shared library. (The versions are only built when needed.) I don't remember if it also handles -fPIE similarly smartly though if you do want position-independent executables.
Re:0+0 > 0: C++ thread-local storage performance by 1718627440 on Tuesday February 18, 2025 @04:27AM (#43087714)
> I don't think build systems add -fPIC automatically, nor remove it automatically.

GNU Autotools do, if you tell, that you have a shared library. You can also switch between static/dynamic linking at build time and if you also use GNU Libtool, it will figure out the flags of your build platform at build time.

> as opposed to doing it yourself like make forces you to

You can definitely don't have to do that. GNU Automake does it by default, but if you are using plain Make, you can also use makedepend or the appropriate flags of your compiler.

> either bad ones, like make

What is wrong/missing with make as a task graph executor?

> or good ones, like Bazel

What can Bazel do better?