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

LLVM 20 #22780

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft

LLVM 20 #22780

wants to merge 32 commits into from

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Feb 6, 2025

Currently targeting LLVM 20.1.0, but aiming for LLVM 20.1.1 by the time this is merged.

Test suite status:

  • test-fmt: ✔️
  • test-cases: ✔️
  • test-translate-c: ✔️
  • test-run-translated-c: ✔️
  • test-behavior: ✔️
  • test-c-import: ✔️
  • test-compiler-rt: ✔️
  • test-universal-libc: ✔️
  • test-std: ✔️
  • test-unit: ✔️
  • test-compare-output: ✔️
  • test-standalone: ✔️
  • test-c-abi: ✔️
  • test-link: ✔️
  • test-stack-traces: ✔️
  • test-cli: ✔️
  • test-asm-link: ✔️
  • test-debugger: ✔️
  • test-incremental: ✔️

Bugs filed upstream:

Closes #22014.

@alexrp alexrp added work in progress This pull request is not ready for review yet. release notes This PR should be mentioned in the release notes. backend-llvm The LLVM backend outputs an LLVM IR Module. labels Feb 6, 2025
@alexrp alexrp added this to the 0.15.0 milestone Feb 6, 2025
@alexrp alexrp added the zig cc Zig as a drop-in C compiler feature label Feb 6, 2025
@alexrp alexrp marked this pull request as draft February 6, 2025 06:04
@alexrp alexrp force-pushed the llvm20 branch 3 times, most recently from 58b5963 to 68de6ef Compare March 5, 2025 09:35
@alexrp

This comment was marked as resolved.

@alexrp

This comment was marked as resolved.

@mlugg

This comment was marked as resolved.

@alexrp
Copy link
Member Author

alexrp commented Mar 9, 2025

This is now green on x86_64-linux with -fqemu -fwasmtime --glibc-runtimes. Once LLVM 20.1.1 is out, we should hopefully be able to revert 2e48399 and 64bcbda, and then put that LLVM version on the CI machines to see what the situation on macOS and Windows looks like.

alexrp added 8 commits March 10, 2025 08:23
This needs to be cherry-picked to master when we want to start testing the
llvm20 branch on the CI machines.
See:

* https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319
* https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701

We're dropping support for C++03 for Zig due to the first change; it would be
insane to ship 1018 duplicate header files just for this outdated use case.

As a result of the second change, I had to bring in a subset of the headers from
llvm-libc since libc++ now depends on these. Hopefully we can continue to get
away with not copying the entirety of llvm-libc.
alexrp added 24 commits March 10, 2025 08:23
LLVM is increasingly making use of this module flag when present.
This ABI bug was fixed in LLVM 20.
LLVM 20 started tail-calling it in some of our test cases, resulting in:

    error: AndMyCarIsOutOfGas
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103ef9d in main (repro)
        return error.TheSkyIsFalling;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103efa5 in main (repro)
        return error.AndMyCarIsOutOfGas;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/lib/std/start.zig:656:37: 0x103ee83 in posixCallMainAndExit (repro)
                const result = root.main() catch |err| {
                                        ^

instead of the expected:

    error: AndMyCarIsOutOfGas
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103f00d in main (repro)
        return error.TheSkyIsFalling;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103f015 in main (repro)
        return error.AndMyCarIsOutOfGas;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:11:9: 0x103f01d in main (repro)
            try bar();
            ^
We can now run these tests as part of test-modules w/o -Dtest-slow-targets.

Closes #21096.
…rectories` tests for mips64(el).

These started failing with LLVM 20 for unclear reasons:

test-std
└─ run test std-mips64-linux.4.19...6.13.4-gnuabi64.2.28-mips64r2-Debug-libc 2798/2878 passed, 2 failed, 78 skipped
error: 'posix.test.test.link with relative paths' failed: expected 2, found 0
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/testing.zig:103:17: 0x1d9e5bf in expectEqualInner__anon_47031 (test)
                return error.TestExpectedEqual;
                ^
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/posix/test.zig:311:9: 0x3650f57 in test.link with relative paths (test)
        try testing.expectEqual(@as(@typeof(nstat.nlink), 2), nstat.nlink);
        ^
error: 'posix.test.test.linkat with different directories' failed: expected 2, found 0
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/testing.zig:103:17: 0x1d9e5bf in expectEqualInner__anon_47031 (test)
                return error.TestExpectedEqual;
                ^
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/posix/test.zig:355:9: 0x3653377 in test.linkat with different directories (test)
        try testing.expectEqual(@as(@typeof(nstat.nlink), 2), nstat.nlink);
        ^
error: while executing test 'zig.system.darwin.macos.test.detect', the following test command failed:
qemu-mips64 -L /opt/glibc/mips64-linux-gnu-n64 /home/alexrp/Source/ziglang/zig-llvm20/.zig-cache/o/22a8c3762ea56ae3a674fa9ad15f6657/test --seed=0xa1dbb43c --cache-dir=/home/alexrp/Source/ziglang/zig-llvm20/.zig-cache --listen=-

test-std
└─ run test std-mips64-linux.4.19...6.13.4-gnuabi64.2.28-mips64r2-Debug-libc 2798/2878 passed, 1 failed, 79 skipped
error: 'posix.test.test.linkat with different directories' failed: expected 2, found 0
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/testing.zig:103:17: 0x1d9e22f in expectEqualInner__anon_47031 (test)
                return error.TestExpectedEqual;
                ^
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/posix/test.zig:356:9: 0x3650b47 in test.linkat with different directories (test)
        try testing.expectEqual(@as(@typeof(nstat.nlink), 2), nstat.nlink);
        ^
error: while executing test 'zig.system.darwin.macos.test.detect', the following test command failed:
qemu-mips64 -L /opt/glibc/mips64-linux-gnu-n64 /home/alexrp/Source/ziglang/zig-llvm20/.zig-cache/o/22a8c3762ea56ae3a674fa9ad15f6657/test --seed=0xa1dbb43c --cache-dir=/home/alexrp/Source/ziglang/zig-llvm20/.zig-cache --listen=-

Unfortunately, neither GDB nor LLDB want to play nice with qemu-mips64(el) at
the moment, so I can't easily debug these failures.
llvm/llvm-project#129843

This will be fixed with LLVM 20.1.1, so revert this commit by then.
…mFloat().

llvm/llvm-project#130408

This will probably be fixed with LLVM 20.1.1, so revert this commit by then.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. release notes This PR should be mentioned in the release notes. work in progress This pull request is not ready for review yet. zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for the LLVM 20 upgrade
2 participants