Open hammerfunctor opened 11 months ago
0.12.0-dev.1849+bb0f7d55e
build.zig:
build.zig
const builtin = @import("builtin"); const std = @import("std"); pub fn build(b: *std.build.Builder) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const exe = b.addExecutable(.{ .name = "cpp-hello", .root_source_file = .{ .path = "hello.cpp" }, .target = target, .optimize = optimize, }); exe.target = std.zig.CrossTarget{ .cpu_arch = .arm, .os_tag = .linux, .abi = .android, .cpu_model = .baseline, .cpu_features_add = std.Target.arm.featureSet(&.{.v7a}), }; exe.setLibCFile(.{ .path = "android-29-armeabi.conf" }); exe.libc_file.?.addStepDependencies(&exe.step); exe.linkLibC(); exe.linkLibCpp(); // exe.linkSystemLibraryName("c"); // exe.linkSystemLibraryName("c++"); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(&exe.step); const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); }
hello.cpp:
hello.cpp
#include <iostream> int main() { std::cout << "Hello World!\n"; return 0; }
android-29-armeabi.conf:
android-29-armeabi.conf
include_dir=/home/guest/AndroidSDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include sys_include_dir=/home/guest/AndroidSDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi crt_dir=/home/guest/AndroidSDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/29/ msvc_lib_dir= kernel32_lib_dir= gcc_dir=
Output:
zig build-exe cpp-hello Debug native: error: the following command failed with 3 compilation errors: /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/zig build-exe /home/guest/arm32-libcxx/hello.cpp -lc++ -lc --libc /home/guest/arm32-libcxx/android-29-armeabi.conf --cache-dir /home/guest/arm32-libcxx/zig-cache --global-cache-dir /home/guest/.cache/zig --name cpp-hello -target arm-linux-android -mcpu baseline --listen=- Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none) install transitive failure └─ install cpp-hello transitive failure └─ zig build-exe cpp-hello Debug native 3 errors error: unable to build libunwind: SubCompilationFailed error: unable to build libcxx: SubCompilationFailed error: unable to build libcxxabi: SubCompilationFailed
Output without setting libc file:
zig build-exe cpp-hello Debug native: error: the following command failed with 4 compilation errors: /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/zig build-exe /home/guest/arm32-libcxx/hello.cpp -lc++ -lc --cache-dir /home/guest/arm32-libcxx/zig-cache --global-cache-dir /home/guest/.cache/zig --name cpp-hello -target arm-linux-android -mcpu baseline --listen=- Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none) install transitive failure └─ install cpp-hello transitive failure └─ zig build-exe cpp-hello Debug native 4 errors /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/lib/libcxx/include/__config:430:14: error: 'features.h' file not found # include <features.h> ^~~~~~~~~~~~~ /home/guest/arm32-libcxx/hello.cpp:1:10: note: in file included from /home/guest/arm32-libcxx/hello.cpp:1: #include <iostream> ^ /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/lib/libcxx/include/iostream:36:10: note: in file included from /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/lib/libcxx/include/iostream:36: #include <__assert> // all public C++ headers provide the assertion handler ^ /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/lib/libcxx/include/__assert:13:10: note: in file included from /home/guest/bin/share/zig-linux-x86_64-0.12.0-dev.1849+bb0f7d55e/lib/libcxx/include/__assert:13: #include <__config> ^ error: unable to build libunwind: SubCompilationFailed error: unable to build libcxx: SubCompilationFailed error: unable to build libcxxabi: SubCompilationFailed
Build
Also seeing SubCompilationFailed for a freestanding Armv7 cortex_r5f
SubCompilationFailed
libcxx upstream - reference
libcxx
Zig Version
0.12.0-dev.1849+bb0f7d55e
Steps to Reproduce and Observed Behavior
build.zig
:hello.cpp
:android-29-armeabi.conf
:Output:
Output without setting libc file:
Expected Behavior
Build