7225 Commits

Author SHA1 Message Date
Andrew Kelley
a418c59546 link.MachO: fix merge conflict artifact
This happened from cherry-picking bug fixes from master branch.
2022-02-02 22:13:45 -07:00
Andrew Kelley
a0cd4c0f32 CLI: link_libcpp implies link_libc
Improves a warning message for some cases of using `zig run -lc++`.
2022-02-02 22:11:08 -07:00
Jakub Konka
d107ef8697 Merge pull request #10769 from ziglang/link-lib-fixes
stage2: handle name-qualified imports in sema, add a zerofill sections workaround to incremental macho
2022-02-02 22:10:59 -07:00
Jonathan Marler
eace6906ce remove __muloti4 from libc++
fixes https://github.com/ziglang/zig/issues/10719

compiler_rt already provides __muloti4 but libc++ is also providing it and when linking libc++ it causes a crash on my windows x86_64 machine.
2022-02-02 22:04:42 -07:00
Andrew Kelley
e9d916571a link: ELF, COFF, WASM: honor the "must_link" flag of positionals
Previously only the MachO linker was honoring the flag.
2022-02-02 22:00:38 -07:00
Andrew Kelley
021c1190af stage2: .stub files are yet another c++ source file extension
however .cu files are a superset of c++.
2022-02-02 22:00:16 -07:00
Andrew Kelley
45cd1114f7 stage2: make cuda file extensions a separate enum tag than c++
follow-up to 2f41bd3be438dae2a188cfae3295dc28f4e9d434.
2022-02-02 22:00:12 -07:00
Daniel Saier
922d33e5b9 zig cc: Treat cu files as C++ source files
First step towards #10634.

Treating stub files as C++ allows to use zig c++ as a host
compiler for nvcc.

Treating cu files as C++ allow using zig c++ as a host compiler in
CMake. CMake calls the host compiler with -E on a cu file to identify
the compiler.

Using zig c++ to directly compile CUDA code is untested.
2022-02-02 21:52:52 -07:00
Andrew Kelley
936294e32a Merge pull request #10699 from motiejus/arm64
[linux headers] rename arm64 to aarch64
2022-02-02 21:51:58 -07:00
Andrew Kelley
7e61bdbaa4 zig cc: add --hash-style linker parameter
This is only relevant for ELF files.

I also fixed a bug where passing a zig source file to `zig cc` would
incorrectly punt to clang because it thought there were no positional
arguments.
2022-02-02 21:50:52 -07:00
Andrew Kelley
e37c55bae0 link: Elf, Wasm: forward strip flag when linking with LLD 2022-02-02 21:47:28 -07:00
Andrew Kelley
93545fe74f zig cc: detect more linker args
* --whole-archive, -whole-archive
 * --no-whole-archive, -no-whole-archive
 * -s, --strip-all
 * -S, --strip-debug
2022-02-02 21:46:28 -07:00
Andrew Kelley
148b963a60 Merge pull request #10584 from ziglang/macho-rustc-fixes
zld: a couple of fixes which result in better rustc support
2022-02-02 21:45:44 -07:00
Andrew Kelley
af844d865f stage1: remove the "referenced here" error note
It's generally noise. The parts where it is useful will need to be
redone to not be annoying for the general case.
2022-02-02 21:22:57 -07:00
Jakub Konka
252fb642d5 macho: do not write out ZEROFILL physically to file
Prior to this change, `__DATA,__bss` and `__DATA,__thread_bss` would
get actually, physically written out to the output file, unnecessarily
filling the output file with 0s.
2022-02-02 21:22:15 -07:00
Andrew Kelley
18fabd99cc Merge pull request #10475 from lithdew/master
lld: allow for entrypoint symbol name to be set
2022-02-02 21:19:18 -07:00
John Schmidt
afd1f7ed47 Implement segfault handler for macOS x86_64 2022-02-02 21:18:45 -07:00
riverbl
2ac7aefe2f stage2: do not interpret identifier containing underscores (eg: u3_2) as int primitive type 2022-02-02 21:17:25 -07:00
riverbl
bc90a2a083 translate-c: Fix issues translating macro define of hex float constant
* Fix incorrect result when the first digit after the decimal point is not 0-9 - eg 0x0.ap0
* Fix compiler panic when the number starts with `0X` with a capital `X` - eg 0X0p0
* Fix compiler panic when the number has a decimal point immediately after `0x` - eg 0x.0p0
2022-02-02 21:15:15 -07:00
Jakub Konka
57d7ad9172 macho: code signature needs to be 16 bytes aligned 2022-02-02 21:10:23 -07:00
Andrew Kelley
e67e15a29a Merge pull request #10587 from xxxbxxx/master
restore compatibility with glibc<=2.33 for global initializers
2022-02-02 21:10:05 -07:00
Marc Tiehuis
06ae13fe35 stage1: fix bigint_init_bigfloat for single-limb negative floats
Fixes #10592.
2022-02-02 21:09:36 -07:00
Jakub Konka
dafbc6eb25 Merge branch 'Luukdegram-linker-eport-symbols' 2022-01-12 12:01:32 -07:00
Andrew Kelley
6f49233ac6 Merge pull request #10572 from Luukdegram/wasm-linker-stack
Stage2: wasm-linker - Place stack at the beginning of the linear memory
2022-01-12 12:00:03 -07:00
riverbl
bb8eef8d24 translate-c: Fix macro define of float constant using scientific notation
Fixes compiler attempting to use null value when translating macro define of float constant using scientific notation with no decimal point
2022-01-12 11:59:30 -07:00
Evan Haas
53e41682ba translate-c: Handle typedef'ed void return type for functions.
Fixes #10356
2022-01-12 11:58:42 -07:00
Jakub Konka
3542dcad33 zig cc: integration with sysroot arg (#10568)
Prior to this change, even if the use specified the sysroot on the
compiler line like so

```
zig cc --sysroot=/path/to/sdk
```

it would only be used as a prefix to include paths and not as a prefix
for `zig ld` linker.
2022-01-12 11:58:36 -07:00
Jakub Konka
1c61038255 Build fs/filesystem libcxx module when targeting GNU Win 2022-01-12 11:57:40 -07:00
Andrew Kelley
675590cd44 Merge pull request #10499 from paulsnar/paulsnar/stage1-packed-structs-cabi
stage1: Fix LLVM C ABI type resolution for small packed structs
2022-01-12 11:54:04 -07:00
Jimmi Holst Christensen
1676729c66 fmt: Refactor parsing of placeholders into its own function
This saves on comptime format string parsing, as the compiler caches
comptime calls. The catch here, is that parsePlaceHolder cannot take the
placeholder string as a slice. It must take it as an array by value for
the caching to occure.

There is also some logic in here that ensures that the specifier_arg is
always them same slice when the items they contain are the same. This
makes the compiler stamp out less copies of formatType.
2022-01-12 11:53:07 -07:00
Marian Beermann
47e3deeeaa stage1: fix @errorName null termination 2022-01-12 11:51:10 -07:00
Veikka Tuominen
9a0010b186 stage1: fix access of slice sentinel at comptime 2021-12-31 14:23:49 -07:00
joachimschmidt557
ecf0050a92 stage2 AArch64: Implement saving callee-saved registers 2021-12-19 23:24:44 -08:00
Kenta Iwasaki
5c7f2ab011 stage1: deal with BPF not supporting @returnAddress()
Make `@returnAddress()` return for the BPF target, as the BPF target for
the time being does not support probing for the return address. Stack
traces for the general purpose allocator for the BPF target is also set
to not be captured.
2021-12-19 23:22:05 -08:00
Isaac Freund
9f9f215305
stage1, stage2: rename c_void to anyopaque (#10316)
zig fmt now replaces c_void with anyopaque to make updating
code easy.
2021-12-19 00:24:45 -05:00
Jakub Konka
a08137330c macho: handle -install_name option for dylibs/MachO
The status quo for the `build.zig` build system is preserved in
the sense that, if the user does not explicitly override
`dylib.setInstallName(...);` in their build script, the default
of `@rpath/libname.dylib` applies. However, should they want to
override the default behaviour, they can either:

1) unset it with

```dylib.setIntallName(null);```

2) set it to an explicit string with

```dylib.setInstallName("somename.dylib");```

When it comes to the command line however, the default is not to
use `@rpath` for the install name when creating a dylib. The user
will now be required to explicitly specify the `@rpath` as part
of the desired install name should they choose so like so:

1) with `build-lib`

```
zig build-lib -dynamic foo.zig -install_name @rpath/libfoo.dylib
```

2) with `cc`

```
zig cc -shared foo.c -o libfoo.dylib -Wl,"-install_name=@rpath/libfoo.dylib"
```
2021-12-18 17:55:53 -08:00
Jacob G-W
9a8fdbe0a0 plan9 linker: fix off by 1 error 2021-12-18 17:54:20 -08:00
joachimschmidt557
9892684d35 stage2 ARM: spill insts currently in compare flags if necessary 2021-12-18 15:23:25 -08:00
Lee Cannon
d54ba76e40 TracyAllocator: correct order of free and alloc 2021-12-16 19:09:57 -08:00
Andrew Kelley
9257669cd4 glibc: do not pass -DSHARED to any of the libc_nonshared.a sources
This essentially reverts 6a12dce207114842e2e49a3aeb18af01ab207f0b but it
leaves breadcrumbs in the source explaining why things are the way they
are.
2021-12-16 03:34:20 -07:00
Andrew Kelley
e1436873a3 glibc: don't pass -frounding-math
glibc wants this flag but clang (our C compiler) does not support it.
2021-12-16 03:01:13 -07:00
Andrew Kelley
37fa6f955d glibc: add stat_t64_cp.c to libnonshared.a
Fixes 32-bit architectures.
2021-12-16 03:01:13 -07:00
Andrew Kelley
afb1652c50 glibc: i386: make glibc not use invalid inline asm syntax 2021-12-16 03:01:13 -07:00
Andrew Kelley
6a12dce207 glibc: fix some inconsistent flags with upstream
This more correctly matches what glibc does to build the objects
inside libnonshared.a.
2021-12-16 03:01:13 -07:00
Andrew Kelley
c9863c0a0c CLI: helpful error message when libc requested but not provided 2021-12-16 03:01:13 -07:00
Andrew Kelley
c8af00c66e glibc: fix inconsistency of powerpc ABI mapping
See the commit message of 5b6d26e97bb97d79782f3c77b02a997e361a1497 for
an explanation. This is the same thing but for powerpc instead of mips.
2021-12-16 03:01:13 -07:00
Andrew Kelley
5b6d26e97b glibc: fix inconsistency of mips ABI mapping
Before this commit, glibc headers did the following mapping:

 * (zig) mipsel-linux-gnu      => (glibc) mipsel-linux-gnu
 * (zig) mipsel-linux-gnu-soft => (glibc) (none)
 * (zig) mips-linux-gnu        => (glibc) mips-linux-gnu
 * (zig) mips-linux-gnu-soft   => (glibc) (none)

While the glibc ABI stubs used the (zig) gnueabi and gnueabihf ABIs,
and the stage2 available_libcs array listed:

 * (zig) mipsel-linux-gnu
 * (zig) mips-linux-gnu

The problem is the mismatch between the ABI component of the headers and
the stubs.

This commit makes the following clarifications:

 * (zig) mips-linux-gnueabi     means soft-float
 * (zig) mipsel-linux-gnueabi   means soft-float
 * (zig) mips-linux-gnueabihf   means hard-float
 * (zig) mipsel-linux-gnueabihf means hard-float

Consequently, the glibc headers now do this mapping:

 * (zig) mips-linux-gnueabihf   => (glibc) mips-linux-gnu
 * (zig) mipsel-linux-gnueabihf => (glibc) mipsel-linux-gnu
 * (zig) mips-linux-gnueabi     => (glibc) mips-linux-gnu-soft
 * (zig) mipsel-linux-gnueabi   => (glibc) mipsel-linux-gnu-soft

The glibc ABI stubs are unchanged, and the stage2 available_libcs
array's 2 entries are modified and it gains 2 more:

 * (zig) mipsel-linux-gnueabi
 * (zig) mipsel-linux-gnueabihf
 * (zig) mips-linux-gnueabi
 * (zig) mips-linux-gnueabihf

Now everything is consistent. Zig no longer recognizes a `mips-linux-gnu`
triple; one must use `mips-linux-gnueabi` (soft float) or
`mips-linux-gnueabihf` (hard float).
2021-12-15 19:09:50 -07:00
Andrew Kelley
e977455f7c glibc: improve RISC-V support
* omit crti.o / crtn.o for this architecture
 * add missing entry.h header from upstream
2021-12-15 18:34:27 -07:00
Andrew Kelley
4d48948b52 glibc: pass -D__GLIBC_MINOR__=XX
instead of hard-coding it. This means that C code has accurate glibc
version information in the preprocessor.
2021-12-15 17:52:27 -07:00
Andrew Kelley
3dcd3612dc glibc: use linux-specific files for nonshared
Upstream, some of the nonshared functions moved to be different for hurd
and for linux. Since our glibc is linux-only we update to use the
linux-specific files.

This fixes std lib tests for x86_64 when linking glibc.
2021-12-15 15:23:56 -07:00