1
Fork 0
Commit Graph

118 Commits

Author SHA1 Message Date
Motiejus Jakštys 0302fb630a defs: fix import paths
Empirically these need to come from most specfic to least specific.

The error message is as follows:

    In file included from test/c/main.c:1:
    In file included from external/zig_sdk/lib/libcxx/include/stdio.h:107:
    In file included from external/zig_sdk/lib/libc/include/generic-glibc/stdio.h:38:
    external/zig_sdk/lib/libc/include/generic-glibc/bits/types.h:139:3: error:
    # error
      ^
    external/zig_sdk/lib/libc/include/generic-glibc/bits/types.h:145:1: error: unknown type name '__STD_TYPE'
    __STD_TYPE __DEV_T_TYPE __dev_t;        /* Type of device numbers.  */

Dissected `generic-glibc/bits/types.h:#error`:

    #if __WORDSIZE == 32
    <...>
    # define __STD_TYPE		__extension__ typedef
    #elif __WORDSIZE == 64
    <...>
    # define __STD_TYPE		typedef
    #else
    # error
    #endif

So we do not have the `__WORDSIZE`. Where does that come from? Probably from a
directory that has an `x86_64` in it. How does that get included? Let's start
with `lib/libcxx/include/stdio.h`:

	16 #include_next <stdio.h>

Now previously our `c++` command line looked like this:
    external/zig_sdk/tools/c++ \
    <...>
    -Iexternal/zig_sdk/lib/include \
    -Iexternal/zig_sdk/lib/libcxx/include \
    -Iexternal/zig_sdk/lib/libcxxabi/include \
    -Iexternal/zig_sdk/lib/libunwind/include \
    -Iexternal/zig_sdk/lib/libc/include/generic-glibc \
    -Iexternal/zig_sdk/lib/libc/include/any-linux-any \
    -Iexternal/zig_sdk/lib/libc/include/x86_64-linux-gnu \
    -Iexternal/zig_sdk/lib/libc/include/x86_64-linux-any \
    -Iexternal/zig_sdk/lib/libc/include/x86-linux-any \
    -Iexternal/zig_sdk/glibc-hacks \
    <...>

So the next place it will find `stdio.h` is in `generic-glibc`, which already
uses the `__WORDSIZE`. If we make the "next" include to be the arch-specific
one instead of the generic-glibc, things start compiling again.

Fix the same fo musl.
2022-09-27 10:15:02 +03:00
Ken Micklas ab59c18d60 WIP: use relative paths for tools 2022-09-27 10:14:59 +03:00
Motiejus Jakštys f6b16c386f upgrade to zig 0.10.0-dev.4166+cae76d829
- llvm 15
- uses less space for /tmp/bazel-zig-cc
2022-09-25 13:51:59 +03:00
Motiejus Jakštys 026d234bc2 Revert "bump to zig 0.10.0-dev.3999+fda6d4477"
This reverts commit f161caf870.

This version has a bug that's been fixed upstream, but a new nightly did
not come out yet: https://github.com/ziglang/zig/issues/12858
2022-09-22 11:57:39 +03:00
Ken Micklas 64b6c702db Fix include root path for macos-aarch64 2022-09-15 22:19:06 +03:00
Ken Micklas ba0b0376ea Move Label dependencies above archive fetching to reduce restarts 2022-09-15 22:18:43 +03:00
Motiejus Jakštys f161caf870 bump to zig 0.10.0-dev.3999+fda6d4477
llvm 15
2022-09-14 11:54:04 +03:00
Motiejus Jakštys bf32b5ee92 repository_rule: depend on $BAZEL_ZIG_CC_CACHE_PREFIX
Otherwise the repository doesn't get re-downloaded/wiped when this
parameter changes.
2022-09-12 13:46:07 +03:00
Motiejus Jakštys e1d699f7ed upgrade to 0.10.0-dev.3838+77f31ebbb 2022-09-01 09:28:43 +03:00
Motiejus Jakštys 79674a1d96 replace /usr/bin/env sh with /bin/sh
/bin/sh exists in NixOS and in fact is the only file in `/bin`:

    $ docker run -ti --rm nixos/nix ls /bin /usr/bin
    /bin:
    sh

    /usr/bin:
    env

More context in
https://lists.sr.ht/~motiejus/bazel-zig-cc/%3CCAFVMu-pvNx%2BpeQYdge_fvmSGrHDmn78VmoYwTxkDgMjbzfVAwQ%40mail.gmail.com%3E
2022-08-30 09:21:27 +03:00
Motiejus Jakštys 342b239bb9 nit: style of cache prefix definition 2022-08-29 14:44:38 +03:00
Motiejus Jakštys e861c5b4be cache_prefix: clean up OS logic
'Windows' and 'Other' and guessing of cache prefix was convoluted
2022-08-29 13:01:09 +03:00
Fabian Hahn a410141ca4 add cache prefix configuration for Windows 2022-08-28 20:18:21 +03:00
Motiejus Jakštys 15f9578591 use a specific template if cache prefix is known 2022-08-26 10:55:29 +03:00
Ken Micklas 0612c6ed9c Support configuring cache prefix with an environment variable
The user may want to build with `--sandbox_tmpfs_path=/tmp`, in which
case the Zig cache will not be shared between sandboxes, massively
slowing down the build. With this feature, the user can pass flags
like `--repo_env=BAZEL_ZIG_CC_CACHE_PREFIX=$HOME/.cache/bazel-zig-cc`
together with `--sandbox_writable_path=$HOME/.cache/bazel-zig-cc` to
put the cache somewhere else which can be shared between sandboxes.
2022-08-26 10:47:25 +03:00
Motiejus Jakštys db7beefbe4 c++: fall back to cache dir in /tmp
rules_go is making calls that do `env - <...>` and are setting neither
TMPDIR nor HOME. So we should always fallback somewhere.
2022-08-12 09:25:37 +03:00
Motiejus Jakštys e50d1597f4 upgrade zig sdk to one of last night 2022-08-12 05:38:34 +03:00
Luis Holanda c4125cf13b Support NixOS and others non-FHS Linux distros
As it expects Bash to be at `/bin/bash`, the current implementation
fails to execute on NixOS, given that there bash is in a non-standard
path (i.g. `/nix/store/<hash>-bash-interactive-<version>/bin/bash`).

This patch specifically changes `/bin/bash` paths to use `/usr/bin/env bash`,
which should give the correct path in every Unix system.

Signed-off-by: Luis Holanda <luiscmholanda@gmail.com>
2022-07-28 12:44:57 -07:00
Motiejus Jakštys df11a2af38 bump zig to 0.10.0-dev.2977+7d2e14267"
changes:
- upgrade from llvm 13 to llvm 14
- add --compress-debug-sections=zlib
2022-07-12 14:09:11 +03:00
Motiejus Jakštys 0818e20167 bump zig upstream 2022-07-04 15:39:41 +03:00
Motiejus Jakštys b7da83e13e upgrade zig sdk
Also fix darwin zigtarget to none; see 5b813f1a2acdc1668e39008b02a234f3da724552 of zig
2022-06-28 12:47:23 +03:00
Motiejus Jakštys 86ae317685 zig sdk: rename {ext} to {_ext}
Also update README and release scripts
2022-06-06 10:32:42 +03:00
Fabian Hahn 4a6eef7945 added Windows host support 2022-06-02 05:27:22 +03:00
Motiejus Jakštys 8fec0e3441 zig sdk: download from zig upstream as well as jakstys.lt
Now that the toolchain supports multiple mirrors, we can have more
robust defaults: try ziglang.org first, then dl.jakstys.lt when that one
removes the build we rely on.

This will make builds less prone to inevitable failures of my home
server.
2022-05-18 10:42:51 +03:00
Motiejus Jakštys 0044260206 upgrade zig to 0.10.0-dev.2252+a4369918b 2022-05-17 14:41:02 +03:00
Motiejus Jakštys 4fa5eff207 [linux-aarch64] fix top-level include path 2022-05-06 10:46:32 +03:00
Motiejus Jakštys 94d5864cb7 move `--no-gc-sections` hack to the toolchain definition
Thanks laurynasl for the tip.
2022-05-05 14:36:36 +03:00
Motiejus Jakštys 9ce21b5276 [zig ld] --gc-sections workaround + tests
`zig cc` emits `--gc-sections` for the linker, which is incompatbile
with what CGo thinks about linking.

This commit adds a workaround: it will add `--no-gc-sections` to the
linking step if the command is not specified (falling back to the
default behavior of gcc/clang).

Related: https://github.com/golang/go/issues/52690
2022-05-05 13:36:58 +03:00
laurynasl 4d65b80903 Add libc constraint and libc aware toolchains
- Also get rid of @bazel_skylib dependency
2022-04-14 14:29:06 +00:00
laurynasl 68b152067c Fix register toolchain 2022-04-09 00:09:04 +03:00
laurynasl 64be98b830 Hide toolchain internals 2022-04-07 11:23:40 +00:00
Motiejus Jakštys 6ded50ad67 buildifier 2022-04-07 13:21:44 +03:00
laurynasl eedfc3312e Move toolchain definitions to toolchains/ 2022-04-07 12:43:34 +03:00
laurynasl 723e6f051d Move toolchainss under @zig_sdk//platform: 2022-04-07 12:43:34 +03:00
laurynasl d1b0dddf8c Move declare_platforms() to platform/ 2022-04-07 12:43:34 +03:00
laurynasl dd76e0b76f move platforms under @zig_cc//platform: 2022-04-07 12:43:34 +03:00
Ken Micklas ccb68098e6 Use upstream read_user_netrc from Bazel 5.1 2022-03-26 15:56:11 +02:00
Ken Micklas fc62c3a7b7 Remove repo fetch-time uname dependency, use new os.arch instead 2022-03-26 15:56:11 +02:00
Motiejus Jakštys 3492880151 bump to zig-0.10.0-dev.1393+291f5055f 2022-03-18 06:06:08 +01:00
Ken Micklas 9afcddea4f Support netrc for Zig SDK download 2022-03-18 06:04:49 +01:00
Motiejus Jakštys 2895f0c2bf replace `url_format` with `url_formats` 2022-03-18 05:44:22 +01:00
Ken Micklas fb0cf50c44 2022-03-18 05:30:42 +01:00
Ken Micklas fcb3d0432e Starlark's default argument semantics are pretty weird and likely not
what you would expect:
https://github.com/bazelbuild/starlark/blob/master/spec.md#functions

Additionally, this is just easier to read.
2022-03-18 05:30:38 +01:00
Ken Micklas 9ede1507c3 Fix and adjust darwin libc header paths depending on CPU 2022-02-11 06:29:46 +02:00
Ken Micklas 77688d0a45 Interpret arm64 output from uname as aarch64 on mac OS 2022-02-11 06:29:07 +02:00
Motiejus Jakštys bcd9731f92 add @zig_sdk//:<os>_<arch>_platform values 2022-02-03 14:24:26 +02:00
Motiejus Jakštys d27f6be570 upgrade to 0.10.0-dev.513+029844210 2022-02-02 14:59:34 +02:00
Motiejus Jakštys faae381685 upgrade zig to 0.10.0-dev.430+35423b005 2022-01-27 10:52:25 +02:00
Motiejus Jakštys 2d32bfe884 upgrade zig to 0.10.0-dev.399+366c76744
Implements -whole-archive, -no-whole-archive, -s, -S in
50905d88518f92a9b8e492daf8dbb6d38b7c61bf
2022-01-26 05:41:21 +02:00
Motiejus Jakštys 78f3a59f0c [readme] less bragging about the home server 2022-01-25 11:19:52 +02:00