Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github, config: use Zig to cross compile arm64 Linux asset #460

Merged
merged 19 commits into from
Aug 16, 2023

Commits on Aug 14, 2023

  1. config: support zigcc locally

    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    0546176 View commit details
    Browse the repository at this point in the history
  2. .github: support zigcc in CI

    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    4dae1da View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bc75361 View commit details
    Browse the repository at this point in the history
  4. nimble: strip comment section from binary

    With the Zig 0.9.0 release (2021-12-20), the configlet binary now has
    30 KiB of bloat in the comment section, repeating the clang version many
    times.
    
    Before this commit:
    
        $ readelf -p .comment ./configlet
    
        String dump of section '.comment':
          [     0]  clang version 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 74211dd7f7e7174a2027641dfcfdb3fc5df62f0c)
          [...] (repeat for 30 KB)
          [  7969]  clang version 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 74211dd7f7e7174a2027641dfcfdb3fc5df62f0c)
          [  79d2]  Linker: LLD 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 74211dd7f7e7174a2027641dfcfdb3fc5df62f0c)
    
    Binary size profile before this commit:
    
           FILE SIZE        VM SIZE
        --------------  --------------
         75.2%   368Ki  64.5%   368Ki    .text
          0.0%       0  19.6%   111Ki    .bss
         18.2%  89.1Ki  15.6%  89.1Ki    .rodata
          6.2%  30.6Ki   0.0%       0    .comment
          0.2%     816   0.1%     824    .data
          0.1%     640   0.0%       0    [ELF Section Headers]
          0.1%     392   0.1%     392    [ELF Program Headers]
          0.0%      64   0.0%      64    [ELF Header]
          0.0%      63   0.0%       0    .shstrtab
          0.0%       8   0.0%       8    .got
          0.0%       8   0.0%       8    [LOAD #1 [R]]
          0.0%       4   0.0%       3    .fini
          0.0%       3   0.0%       3    .init
        100.0%   489Ki 100.0%   570Ki    TOTAL
    
    Strip the comment section. But print it first.
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    ceef0c0 View commit details
    Browse the repository at this point in the history
  5. nimble: remove -s flag from strip command

    With Zig 0.10.0 (2022-10-31), `zig cc` now properly uses the `--passL:
    -s` option that we use in `config.nims`. So we can remove the `-s` flag
    from our post-build hook.
    
    From the Zig 0.10.0 release notes [1]:
    
        `zig cc` is Zig's drop-in C compiler tool. Enhancements in this release:
    
        [...]
        - Integration with more linker args:
    
          - `--whole-archive`, `-whole-archive`
          - `--no-whole-archive`, `-no-whole-archive`
          - `-s`, `--strip-all`
          - `-S`, `--strip-debug`
        [...]
    
    [1] https://ziglang.org/download/0.10.0/release-notes.html#zig-cc
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    c3254b7 View commit details
    Browse the repository at this point in the history
  6. configlet: improve status message

    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    c4cf6be View commit details
    Browse the repository at this point in the history
  7. .github, config: cross-compile an arm64 asset

    And install Zig via script, rather than snap. One benefit is that it
    allows us to pin a Zig version.
    
    The script is adapted from one I added to the Exercism Zig repo [1].
    
    [1] exercism/zig@9dfb95f031b1
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    0fd7591 View commit details
    Browse the repository at this point in the history
  8. nimble: comment-out stripping

    `strip` can't strip a non-native executable.
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    abb70ab View commit details
    Browse the repository at this point in the history
  9. .github(cross-compile): fix path

    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    8df0f9b View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    f6aaed8 View commit details
    Browse the repository at this point in the history
  11. .github(cross-compile): try --os:macosx

    --os:macos produced the error:
    
        /home/runner/work/configlet/configlet/nimdir/lib/system/dyncalls.nim(198, 10) Error: no implementation for dyncalls
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    d4403d3 View commit details
    Browse the repository at this point in the history
  12. config: disable LTO for zig + macos

    Try to resolve error:
    
        error: LTO is not yet supported with the Mach-O object format. More details: ziglang/zig#8680
        Error: execution of an external compiler program
        'zigcc -c -w -ferror-limit=3 -pthread -target aarch64-macos-none -flto -Os
        -I/home/runner/work/configlet/configlet/nimdir/lib
        -I/home/runner/work/configlet/configlet/src
        -o /home/runner/.cache/nim/configlet_r/@m..@snimdir@slib@ssystem@sctypes.nim.c.o
        /home/runner/.cache/nim/configlet_r/@m..@snimdir@slib@ssystem@sctypes.nim.c'
        failed with exit code: 1
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    97893f7 View commit details
    Browse the repository at this point in the history
  13. .github(cross-compile): disable aarch-macos target for now

    Disable until we can resolve the error
    
        CC: ../nimdir/lib/std/sysrand.nim
        /home/runner/.cache/nim/configlet_r/@m..@snimdir@slib@sstd@ssysrand.nim.c:9:10:
        fatal error: 'Security/SecRandom.h' file not found
    
    which is due to a recent commit [1].
    
    [1] 53a75a2 ("nimble, uuid: generate UUIDs via std/sysrand, not pragmagic/uuids", 2023-08-07)
    ee7 committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    62ed28c View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2023

  1. .github(cross-compile): try aarch64-windows-gnu

    This probably won't work immmediately.
    ee7 committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    83796fe View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3f8c8df View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    21bf654 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    67dbdd5 View commit details
    Browse the repository at this point in the history
  5. .github(cross-compile), nimble: prepare to strip with llvm-strip

    Our `strip` doesn't support elf64-aarch64 as a target, and `zig objcopy`
    doesn't have a `-R, --remove-section` option. Use llvm-strip when it's
    installed.
    ee7 committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    eea45c8 View commit details
    Browse the repository at this point in the history
  6. .github(cross-compile): format with shfmt

    Format with
    
      shfmt -i 2 -sr -kp -ci -w ./cross-compile
    ee7 committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    3e97a25 View commit details
    Browse the repository at this point in the history