Skip to content

LLVM #713

Open
Open

Description

@TeamPuzel

Hello,

I am interested in using the ps2sdk libraries with LLVM, enabling use of many modern languages, mostly Zig and Swift 🙂

This project appears to be using a custom GCC target. What are the reasons for it, what does it do, and where can I find such documentation? This seems to require a new LLVM target to match, but I'm not sure where to start. I don't seem to be able to link the libraries with LLVM object files otherwise.

Activity

  1. rickgaiser commented on Jan 5, 2025

    @rickgaiser
    Member

    LLVM does have support for the normal MIPS CPU's. However the generated MIPS code is not as good as what gcc generates (more instructions to do the same thing).

    LLVM does not support MIPS R5900.
    GCC has basic MIPS R5900 support (but not complete)

    You can try compiling with LLVM to MIPS III (ABI n32) as that should be compatible. But you'll probably be the first to do so, so expect a lot of issues.

    Search for:

    • TOSHIBA C790 superscalar microprocessor
    • EE R5900

    To get more information.

  2. 10522 commented on Jan 8, 2025

    @10522
  3. TeamPuzel commented on Jan 8, 2025

    @TeamPuzel
    Author

    @10522 I know about it, but it's not actually using LLVM. It's using Zig's ability to compile directly to C code, and then compiling that C code using this sdk.

    What I want is to do is get LLVM itself working for this target and LLVM doesn't support compiling to C, It's a feature specific to Zig.

    Unfortunately my choice of languages seems to be limited:

    • Can't use modern C++ because I doubt there is a libc++ port for this platform, cross compiling to a modern platform like Windows was already a nightmare.
    • Can't use Zig because its own target triples don't expose all of LLVM's, that seems to include n32 unless it's hidden somewhere.
    • I could use C but at that point LLVM seems like a disadvantage, I can just use this sdk entirely. Especially since I am now told LLVM doesn't generate especially good MIPS.

    I am left with Rust, which I don't like, and Swift which should only require building the standard library for this triple.

    That's a lot of issues even before getting to proper LLVM support, which I can't do anything about — it looks like an insanely complicated codebase. I can see why no one would bother with trying this.

    Still, it does seem like it's possible to hack something together.

  4. uyjulian commented on Jan 8, 2025

    @uyjulian
    Member

    C++ is already supported for EE.

    For other LLVM based languages you can compile to WebAssembly then use wasm2c to convert to C which then can be used as input to gcc.

  5. 10522 commented on Jan 8, 2025

    @10522

    @TeamPuzel you can also use AthenaEnv (JavaScript), Enceladus (Lua) or Prussia (Rust).

  6. 10522 commented on Jan 21, 2026

    @10522

    @TeamPuzel check out this.

  7. rickgaiser commented on Jan 21, 2026

    @rickgaiser
    Member

    Full support EE LLVM compiler (r5900, MMI, VU0 and more) here:
    https://github.com/rickgaiser/llvm-project/tree/EmotionEngine

    Build instructions:

    mkdir build
    cd build
    
    cmake -G Ninja \
      -C ../clang/cmake/caches/PS2EE.cmake \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX="$PS2DEV/llvm" \
      -DLLVM_PARALLEL_LINK_JOBS=4 \
      ../llvm
    
    ninja distribution
    ninja install-distribution
    

    Usage:

    clang --target=mips64el-scei-ps2 -mvu0 ...
    

    GCC and LLVM object files are interchangable. So you can compile your project using LLVM/clang and link libraries from ps2sdk compiled with GCC.

    Attempt to merge the most basic changes upstream here:
    llvm/llvm-project#176666

  8. rickgaiser commented on Jan 22, 2026

    @rickgaiser
    Member

    @TeamPuzel I got Zig working on ps2 with the new LLVM compiler. Code here:
    https://github.com/rickgaiser/test_llvm_zig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions