Attempt to make LLD happy

Things are a little better. The LLD that comes with Linux seems to work.
Old versions like LLVM 8 haven't been supported since Cosmopolitan v0.2.
Running Clang on Windows with --target=x86_64-pc-linux-gnu doesn't seem
to work. It has something to do with the recently added .zip section in
the linker script. But even if that's removed, LLD on Windows thinks it
is building an EFI application for some reason. Linker scripts are such
a brittle house of cards, even for just ld.bfd alone..

We should just find a way to run our one true musl-cross-make linux gcc
toolchain under Blinkenlights on non-Linux because GCC and Clang are so
nondeterministic, inconsistent, and unreproducible when built for other
operating systems. We need an actually portable compiler/linker that'll
always behave the same way no matter what.

See #180
This commit is contained in:
Justine Tunney 2021-07-05 19:10:06 -07:00
parent 0ecd71f697
commit f8b9bd2b47
4 changed files with 9 additions and 2 deletions

View file

@ -375,7 +375,7 @@ SECTIONS {
/*END: file content */
/*BEGIN: bss memory that's addressable */
.bss ALIGN(__SIZEOF_POINTER__) : {
.bss ALIGN(64) : {
KEEP(*(SORT_BY_NAME(.piro.bss.init.*)))
*(.piro.bss)
KEEP(*(SORT_BY_NAME(.piro.bss.sort.*)))

View file

@ -25,3 +25,4 @@
// cc -pg adds this to the start of global functions.
mcount: ret
.endfn mcount,weak
.alias mcount,.mcount # freebsd weirdness?

View file

@ -18,6 +18,7 @@
*/
#include "libc/log/check.h"
#include "libc/math.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/rand/lcg.internal.h"
#include "libc/rand/rand.h"
#include "libc/stdio/stdio.h"
@ -175,7 +176,11 @@ uint64_t GetRandomNoRdrrnd(void) {
uint64_t GetRandomNoSystem(void) {
uint64_t x;
ASSERT_EQ(8, getrandom(&x, 8, GRND_NOSYSTEM));
if (X86_HAVE(RDRND) || X86_HAVE(RDSEED)) {
ASSERT_EQ(8, getrandom(&x, 8, GRND_NOSYSTEM));
} else {
ASSERT_EQ(8, getrandom(&x, 8, 0));
}
return x;
}

View file

@ -14,6 +14,7 @@ if CLANG=$(command -v clang); then
-fno-pie \
-nostdlib \
-nostdinc \
-fuse-ld=lld \
-mno-red-zone \
-Wl,-T,o/$MODE/ape/ape.lds \
-include o/cosmopolitan.h \