ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.86k stars 2.48k forks source link

Cross-compiling x86.Feature.soft_float on Windows fails #5288

Open ilmaria opened 4 years ago

ilmaria commented 4 years ago

I'm trying to use soft floats on a freestanding x86 target with this build.zig:

const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    const exe = b.addExecutable("test", "src/main.zig");

    var cpu = std.Target.Cpu.baseline(.i386);
    cpu.features.addFeature(@enumToInt(std.Target.x86.Feature.soft_float));
    exe.setTarget(b.standardTargetOptions(.{
        .default_target = std.zig.CrossTarget.fromTarget(.{
            .cpu = cpu,
            .os = .{ .tag = .freestanding, .version_range = .{ .none = {} } },
            .abi = .gnu,
        }),
    }));

    exe.setBuildMode(b.standardReleaseOptions());
    exe.install();
}

On Windows, it fails to build with error code 5:

> ..\zig\zig.exe build
test...The following command exited with error code 5:
C:\Users\Ilmari\Downloads\zig\zig.exe build-exe C:\Users\Ilmari\Downloads\test\src\main.zig --cache-dir C:\Users\Ilmari\Downloads\test\zig-cache --name test -target i386-freestanding-gnu -mcpu=pentium4+soft_float --cache on

Build failed. The following command failed:
C:\Users\Ilmari\Downloads\test\zig-cache\o\LPzlaLrFyu9kTzj1tDICzFkD9VHo1PILb7X0-JZTp0nRwFFyM9O_hJR0_5jPP2hE\build.exe C:\Users\Ilmari\Downloads\zig\zig.exe C:\Users\Ilmari\Downloads\test C:\Users\Ilmari\Downloads\test\zig-cache
> zig version
0.6.0+54b2a6ec4
alexrp commented 3 weeks ago
zig: /home/alexrp/Source/llvm-project-18/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8510: llvm::SDValue llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, const llvm::SDLoc&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*): Assertion `MemVT.getScalarType().bitsLT(VT.getScalarType()) && "Should only be an extending load, not truncating!"' failed.
Rexicon226 commented 3 days ago

I get

Should not custom lower this!
UNREACHABLE executed at /home/david/Code/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:32347

on 0.14.0-dev.1632+d83a3f174