Skip to content

Commit b388dc4

Browse files
Merge pull request #8490 from roc-lang/fix-platform-not-supported-linux
fix PlatformNotSupported linux
2 parents 7ac22c8 + a98bc71 commit b388dc4

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

build.zig

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ fn configureBackend(step: *Step.Compile, target: ResolvedTarget) void {
2020
}
2121
}
2222

23+
fn isNativeOrMusl(target: ResolvedTarget) bool {
24+
return target.query.isNativeCpu() and target.query.isNativeOs() and
25+
(target.query.isNativeAbi() or target.result.abi.isMusl());
26+
}
27+
2328
const TestsSummaryStep = struct {
2429
step: Step,
2530
has_filters: bool,
@@ -492,7 +497,24 @@ fn setupTestPlatforms(
492497
b.getInstallStep().dependOn(&copy_test_int_host.step);
493498
test_platforms_step.dependOn(&copy_test_int_host.step);
494499

495-
// Cross-compile int platform host libraries for musl and glibc targets
500+
// Create test platform host static library (fx) - native target
501+
const test_platform_fx_host_lib = createTestPlatformHostLib(
502+
b,
503+
"test_platform_fx_host",
504+
"test/fx/platform/host.zig",
505+
target,
506+
optimize,
507+
roc_modules,
508+
);
509+
510+
// Copy the fx test platform host library to the source directory
511+
const copy_test_fx_host = b.addUpdateSourceFiles();
512+
const test_fx_host_filename = if (target.result.os.tag == .windows) "host.lib" else "libhost.a";
513+
copy_test_fx_host.addCopyFileToSource(test_platform_fx_host_lib.getEmittedBin(), b.pathJoin(&.{ "test/fx/platform", test_fx_host_filename }));
514+
b.getInstallStep().dependOn(&copy_test_fx_host.step);
515+
test_platforms_step.dependOn(&copy_test_fx_host.step);
516+
517+
// Cross-compile int and fx platform host libraries for musl and glibc targets
496518
const cross_compile_targets = [_]struct { name: []const u8, query: std.Target.Query }{
497519
.{ .name = "x64musl", .query = .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl } },
498520
.{ .name = "arm64musl", .query = .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl } },
@@ -519,6 +541,22 @@ fn setupTestPlatforms(
519541
b.getInstallStep().dependOn(&copy_cross_int_host.step);
520542
test_platforms_step.dependOn(&copy_cross_int_host.step);
521543

544+
// Create cross-compiled fx host library
545+
const cross_fx_host_lib = createTestPlatformHostLib(
546+
b,
547+
b.fmt("test_platform_fx_host_{s}", .{cross_target.name}),
548+
"test/fx/platform/host.zig",
549+
cross_resolved_target,
550+
optimize,
551+
roc_modules,
552+
);
553+
554+
// Copy to target-specific directory
555+
const copy_cross_fx_host = b.addUpdateSourceFiles();
556+
copy_cross_fx_host.addCopyFileToSource(cross_fx_host_lib.getEmittedBin(), b.pathJoin(&.{ "test/fx/platform/targets", cross_target.name, "libhost.a" }));
557+
b.getInstallStep().dependOn(&copy_cross_fx_host.step);
558+
test_platforms_step.dependOn(&copy_cross_fx_host.step);
559+
522560
// Generate glibc stubs for gnu targets
523561
if (cross_target.query.abi == .gnu) {
524562
const glibc_stub = generateGlibcStub(b, cross_resolved_target, cross_target.name);
@@ -1040,11 +1078,10 @@ pub fn build(b: *std.Build) void {
10401078
check_fmt_step.dependOn(&check_fmt.step);
10411079

10421080
const fuzz = b.option(bool, "fuzz", "Build fuzz targets including AFL++ and tooling") orelse false;
1043-
const is_native = target.query.isNativeCpu() and target.query.isNativeOs() and (target.query.isNativeAbi() or target.result.abi.isMusl());
10441081
const is_windows = target.result.os.tag == .windows;
10451082

10461083
// fx platform effectful functions test - only run when not cross-compiling
1047-
if (target.query.isNativeCpu() and target.query.isNativeOs() and target.query.isNativeAbi()) {
1084+
if (isNativeOrMusl(target)) {
10481085
// Create fx test platform host static library
10491086
const test_platform_fx_host_lib = createTestPlatformHostLib(
10501087
b,
@@ -1081,7 +1118,7 @@ pub fn build(b: *std.Build) void {
10811118
}
10821119

10831120
var build_afl = false;
1084-
if (!is_native) {
1121+
if (!isNativeOrMusl(target)) {
10851122
std.log.warn("Cross compilation does not support fuzzing (Only building repro executables)", .{});
10861123
} else if (is_windows) {
10871124
// Windows does not support fuzzing - only build repro executables
5.45 KB
Binary file not shown.
2.52 MB
Binary file not shown.
4.92 KB
Binary file not shown.
8.71 MB
Binary file not shown.

0 commit comments

Comments
 (0)