Skip to content

better compile error for mixing how LLVM is linked #12385

@nektro

Description

@nektro

Zig Version

0.10.0-dev.3504+85a3f9b05

Steps to Reproduce

With a Debian 10.10.0 image made from the following commands after logging into root,

apt install curl
apt install git
git clone --progress https://github.com/llvm/llvm-project
git clone --progress https://github.com/ziglang/zig
apt install g++ cmake make python3
cd llvm-project
git checkout release/14.x
mkdir -pv build
cd build
cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_PREFIX_PATH="/root/out" -DCMAKE_INSTALL_PREFIX="/root/out" -DLLVM_ENABLE_PROJECTS='lld;clang' -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_LTO=OFF -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_GO_TESTS=OFF -DCLANG_BUILD_TOOLS=OFF -DCLANG_INCLUDE_DOCS=OFF
make install
cd ../..
cd zig
mkdir -pv build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX='/root/out' -DZIG_OMIT_STAGE2=ON
make
./zig version
./zig cc --version
./zig build -p stage2 -Denable-llvm -Dskip-install-lib-files

Expected Behavior

Successful build.

Actual Behavior

ld.lld: error: unable to find library -lLLVM-14
error: FileNotFound
/root/zig/lib/std/os.zig:2749:19: 0x2e556b in std.os.mkdiratZ (build)
        .EXIST => return error.PathAlreadyExists,
                  ^
/root/zig/lib/std/os.zig:2709:9: 0x2e5453 in std.os.mkdirat (build)
        return mkdiratZ(dir_fd, &sub_dir_path_c, mode);
        ^
/root/zig/lib/std/fs.zig:1359:9: 0x2e5346 in std.fs.Dir.makeDir (build)
        try os.mkdirat(self.fd, sub_path, default_new_dir_mode);
        ^
/root/zig/lib/std/child_process.zig:446:9: 0x32079a in std.child_process.ChildProcess.waitPosix (build)
        return self.term.?;
        ^
/root/zig/lib/std/child_process.zig:187:13: 0x2fe557 in std.child_process.ChildProcess.wait (build)
            return self.waitPosix();
            ^
/root/zig/lib/std/build.zig:1196:22: 0x2f36ed in std.build.Builder.execAllowFail (build)
        const term = try child.wait();
                     ^
/root/zig/lib/std/build.zig:1285:24: 0x375eed in std.build.Builder.execPkgConfigList (build)
        const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore);
                       ^
/root/zig/lib/std/build.zig:1320:13: 0x375c94 in std.build.Builder.getPkgConfigList (build)
            return result;
            ^
/root/zig/lib/std/build.zig:2080:26: 0x35c3da in std.build.LibExeObjStep.runPkgConfig (build)
            const pkgs = try self.builder.getPkgConfigList();
                         ^
/root/zig/lib/std/build.zig:1302:13: 0x375a58 in std.build.Builder.getPkgConfigList (build)
            return res;
            ^
/root/zig/lib/std/build.zig:2080:26: 0x35c3da in std.build.LibExeObjStep.runPkgConfig (build)
            const pkgs = try self.builder.getPkgConfigList();
                         ^
/root/zig/lib/std/os.zig:1680:23: 0x2cb0cd in std.os.openatZ (build)
            .NOENT => return error.FileNotFound,
                      ^
/root/zig/lib/std/fs.zig:1108:13: 0x2b6f2c in std.fs.Dir.openFileZ (build)
            try os.openatZ(self.fd, sub_path, os_flags, 0);
            ^
/root/zig/lib/std/fs.zig:1035:9: 0x2b4d21 in std.fs.Dir.openFile (build)
        return self.openFileZ(&path_c, flags);
        ^
/root/zig/lib/std/fs.zig:2248:24: 0x35fea4 in std.fs.Dir.updateFile (build)
        var src_file = try source_dir.openFile(source_path, .{});
                       ^
/root/zig/lib/std/build.zig:1088:29: 0x362478 in std.build.Builder.updateFile (build)
        const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{});
                            ^
/root/zig/lib/std/build.zig:3413:9: 0x362a30 in std.build.InstallArtifactStep.make (build)
        try builder.updateFile(self.artifact.getOutputSource().getPath(builder), full_dest_path);
        ^
/root/zig/lib/std/build.zig:3648:9: 0x2e5a7e in std.build.Step.make (build)
        try self.makeFn(self);
        ^
/root/zig/lib/std/build.zig:508:9: 0x2e4ecc in std.build.Builder.makeOneStep (build)
        try s.make();
        ^
/root/zig/lib/std/build.zig:502:17: 0x2e4e78 in std.build.Builder.makeOneStep (build)
                return err;
                ^
/root/zig/lib/std/build.zig:463:13: 0x2d7771 in std.build.Builder.make (build)
            try self.makeOneStep(s);
            ^
/root/zig/lib/build_runner.zig:213:21: 0x2d1305 in main (build)
            else => return err,
                    ^
error: the following build command failed with exit code 1:
/root/zig/zig-cache/o/f308e9d11ab0866603c6b08f5ba2f992/build /root/zig/build/zig /root/zig /root/zig/zig-cache /root/.cache/zig -p stage2 -Denable-llvm -Dskip-install-lib-files -Dconfig_h=config.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions