@PeterSommerlad It does.
In this particular case, MSVC rejects one version of invalid code and incorrectly accepts the other. And I even totally understand why: the Modules TS had a different grammar.
Both Clang and gcc are even worse: they accept *both* ill-formed variants. And they don't have the "legacy" excuse.
My inner “clean” coder is very happy to see that making an already small function even smaller made it x4 faster because GCC started to inline it (“Other lessons learned” section).
On the other hand this is something I wouldn’t have expected and it horrifies me.
https://codingnest.com/the-little-things-the-missing-performance-in-std-vector/
@alexr If some "irrelevant" bits in some pointers used by the compiler at runtime change the compiled code, that's some strange compiler bug. Not that they're unheard of, sure, but I now see your question boils down to whether using the #FreeBSD kernel instead of #Linux would trigger bugs in #GCC.
Again, checking this would be a *huge* amount of work. You might think you could at least compare the object-code files easily, but even these are influenced by library headers, they might pull in types with sizes changed between versions, they might even use conditional compilation based on library versions, etc (and yes, that's all "changed compiler input").
To really do this check reliably, you'd have to create the exact same toolchain and used libraries on both systems.
I'll rather focus on getting more software to build/work, so I can finally test some closed-source software... time is limited 😉
I never wrote Assembly in my life, but tonight (for some reason) I thought of disassembling simple C code snippets with Ghidra. So, I started with a hello world and was very surprised to find a much more extensive and complex result compared to my original assembly (obtained with GCC).
I mean, it's a Hello World!
#ghidra #gcc #clang #assembly #asm
Assigning your copyright to the FSF helps defend the GPL and keep software free. Thanks to Gene Goykhman, Sergey Alexandrovich Bugaev, Wang Diancheng, Warren Thomas Everett Wilkinson, and Xinyuan Zhang for assigning their copyright to the FSF! #GNU #Emacs #glibc #GDB #GNUstep #GNUHurd #GNUMach #GCC Learn more at https://u.fsf.org/3ht #CopyrightAssignments
#gnu #emacs #glibc #gdb #gnustep #gnuhurd #gnumach #gcc #CopyrightAssignments
The new #GCC: Convergence and strategic competition - @gulf @iran
https://gulfstateanalytics.com/the-new-gcc-convergence-and-strategic-competition/
I love that they put "usually" in this sentence:
"Humans usually are not as good writing machine code as they are at writing Fortran"
--
About GNU Fortran
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gfortran/About-GNU-Fortran.html
Nicely written article about compiler's optimisation tricks, particularly with pointers
"GCC always assumes aligned pointer accesses" https://trust-in-soft.com/blog/2020/04/06/gcc-always-assumes-aligned-pointer-accesses/ #Embedded #C #Programming #GCC
#gcc #Programming #C #Embedded
Added these symlinks.
#glibc needs some "convincing" to install *everything* to /usr, but it works.
It solves the issue on #aarch64 and #i386 (which both install the program interpreter to /lib by default).
It does NOT solve the issue on #amd64, where the program interpreter is installed to /lib64, but *something* during #GCC build insists on finding it in /usr/lib instead. 🤯
Trying a hack with a hardlink now (after learning that glibc's ldconfig just deletes symlinks to the program interpreter).
#glibc #aarch64 #i386 #amd64 #gcc
And I still have NO idea where these errors regarding the ELF program interpreter come from when building #gcc and its libstdc++. They do NOT appear in the build log, they are somehow just spit to the controlling terminal of #poudriere. And I didn't find anything not working in these packages so far ... 🤯
Compilers Mastodon, does anyone know of examples where major C compilers exploit UB of misaligned loads/stores to produce silent misbehavior?
That's excluding
- Generating instructions that trap if misaligned (e.g. x86 movdqa), because that's not silent.
- Exploiting code that does more than just making misaligned loads/stores, such as calling __builtin_assume_aligned.
(cc @regehr... hmm, who else should I cc. I wish Mastodon had search. #compilers #llvm #gcc)
Today's `gcc` bug https://gcc.gnu.org/PR111051 is a case where `gcc` stopped recognizing some `avx2` primitives on `avx512` code (all on `highway-1.0.6` code again):
#include <immintrin.h>
#pragma GCC target("avx512vl,avx512dq")
void bug(__m256i i) {
volatile auto v1 = _mm256_cvtepi64_pd(i);
}
and failed as `error: inlining failed in call to 'always_inline' '__m256d _mm256_setzero_pd()': target specific option mismatch`
Today's `gcc` bug is https://gcc.gnu.org/PR111048 where `gcc` generated wrong code for `highway-1.0.6` library in `-mavx2` mode.
When handling the following loop:
u8 in_lanes[32];
for (unsigned i = 0; i < 32; i += 2) {
in_lanes[i + 0] = 0;
in_lanes[i + 1] = ((u8)0xff) >> (i & 7);
}
`gcc` broke `i =12` iteration and instead of `i[13] = 0xf;` (`0xff >> 4`) stored something like `i[13] = 0xef;` there.
This idea of instantiating C++ templates with std::variant turns out to be more complicated than I thought once compiler optimizations are enabled, but function attributes provide the fix. The example code now looks like this. Full write up here: https://indii.org/blog/revisited-combinatorial-instantiation-of-templates-with-std-variant/ #cpp #cplusplus #programming #clang #gcc
#cpp #cplusplus #programming #clang #gcc
How often do you have to build #GCC to have a *native* version for #Linux when building on #FreeBSD?
The answer is: 3 times. First a minimal cross-version without #glibc, required to actually *build* glibc. Then, a "full" cross-version using that glibc. And finally, using this full cross-version, the *native* version.
How often do you have to build GCC to find and fix issues in your FreeBSD ports for these 3 stages? The answer is: *countless* times. And it really takes time to build 😞
@thindil That's what I assume as well, once I'm done with the toolchain, architecture-specific differences should be rare (if encountered at all). 🙏
Just finished the cross-version of #glibc for all archs. Two more (#binutils and #gcc) to go for the FULL cross-toolchain. That will be the goal for today, the native toolchain maybe tomorrow 😎
Well ... no, building with #gcc didn't help.
Turns out the issue were #ELF relocation types. I have no idea why #Linux needs them *just* to build the headers (which is all I need for #Linuxulator, cause the actual #kernel will *still* be #FreeBSD), but yep, one type is named slightly differently: R_X86_64_JUMP_SLOT on Linux, R_X86_64_JMP_SLOT on FreeBSD. It has the same value, 7, so for now I just hardcoded it in the port Makefile for the Linux headers. 🙈 (hey, it works 🤷♂️)
#gcc #elf #linux #linuxulator #kernel #freebsd
Trying to get this to the other archs supported by #FreeBSD's #Linuxulator (amd64 and i386), I'm hitting yet another wall: #Linux headers fail to build there. Oh freakin hell, I expected to do quite some adaptions to support all 3 archs, but I didn't expect it to fail at *this* stage 🤯
Already tried to understand what happens in Linux' build system. Well, it's not exactly easy to understand 🙄
Shot in the dark, trying it with #gcc (instead of the base #clang) now... (which will take a while cause my test machine has to *build* this gcc first, bah ....)
#freebsd #linuxulator #linux #gcc #clang