mirror of
https://github.com/ziglang/zig.git
synced 2025-01-19 16:31:52 +00:00
interpret the WASI blob to produce zig2.c and compiler_rt.c
* synchronize zig1.c from zig-wasi external project * change the way argv works to avoid absolute paths * autodetect isatty * compiler_rt: disable some functions when object format is C * add missing flag from config.zig.in The next problem is that compiling compiler_rt.c with gcc gives "conflicting types" errors for `__eqhf2` and friends.
This commit is contained in:
parent
ef447c3eca
commit
39fd77bc16
@ -702,29 +702,24 @@ if(MSVC)
|
||||
set(ZIG2_COMPILE_FLAGS "/std:c99")
|
||||
set(ZIG2_LINK_FLAGS "/STACK:16777216")
|
||||
else()
|
||||
#set(ZIG1_COMPILE_FLAGS "-std=c99 -O2 -march=native")
|
||||
set(ZIG1_COMPILE_FLAGS "-std=c99 -march=native")
|
||||
set(ZIG1_COMPILE_FLAGS "-std=c99 -O2 -march=native")
|
||||
set(ZIG2_COMPILE_FLAGS "-std=c99 -O2 -march=native")
|
||||
set(ZIG2_LINK_FLAGS "-Wl,-z,stack-size=0x10000000")
|
||||
endif()
|
||||
|
||||
add_executable(zig1 ${STAGE1_SOURCES})
|
||||
set_target_properties(zig1 PROPERTIES COMPILE_FLAGS ${ZIG1_COMPILE_FLAGS})
|
||||
#target_include_directories(zig1 PUBLIC "${CMAKE_SOURCE_DIR}/lib")
|
||||
target_link_libraries(zig1 LINK_PUBLIC m)
|
||||
|
||||
|
||||
set(ZIG2_C_SOURCE "${CMAKE_BINARY_DIR}/zig2.c")
|
||||
set(BUILD_ZIG2_ARGS
|
||||
"${CMAKE_SOURCE_DIR}/lib"
|
||||
"${CMAKE_BINARY_DIR}/zig1-cache"
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
zig2
|
||||
"${CMAKE_SOURCE_DIR}/stage1/zig1.wasm"
|
||||
build-exe src/main.zig -ofmt=c -lc
|
||||
--name zig2
|
||||
--pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"
|
||||
--pkg-end
|
||||
-target x86_64-linux-musl # TODO: autodetect in zig1.c
|
||||
--color on # TODO: autodetect in zig1.c
|
||||
-OReleaseFast
|
||||
)
|
||||
|
||||
@ -739,12 +734,11 @@ add_custom_command(
|
||||
set(ZIG_COMPILER_RT_C_SOURCE "${CMAKE_BINARY_DIR}/compiler_rt.c")
|
||||
set(BUILD_COMPILER_RT_ARGS
|
||||
"${CMAKE_SOURCE_DIR}/lib"
|
||||
"${CMAKE_BINARY_DIR}/zig1-cache"
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
compiler_rt
|
||||
"${CMAKE_SOURCE_DIR}/stage1/zig1.wasm"
|
||||
build-obj lib/compiler_rt.zig -ofmt=c
|
||||
--name compiler_rt
|
||||
-target x86_64-linux-musl # TODO: autodetect in zig1.c
|
||||
--color on # TODO: autodetect in zig1.c
|
||||
-OReleaseFast
|
||||
)
|
||||
|
||||
@ -757,13 +751,9 @@ add_custom_command(
|
||||
)
|
||||
|
||||
|
||||
add_executable(zig2 ${ZIG2_C_SOURCE})
|
||||
add_executable(zig2 ${ZIG2_C_SOURCE} ${ZIG_COMPILER_RT_C_SOURCE})
|
||||
set_target_properties(zig2 PROPERTIES
|
||||
COMPILE_FLAGS ${ZIG2_COMPILE_FLAGS}
|
||||
LINK_FLAGS ${ZIG2_LINK_FLAGS}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
target_include_directories(zig2 PUBLIC "${CMAKE_SOURCE_DIR}/lib")
|
||||
|
@ -3,13 +3,6 @@ const builtin = @import("builtin");
|
||||
pub const panic = @import("compiler_rt/common.zig").panic;
|
||||
|
||||
comptime {
|
||||
_ = @import("compiler_rt/atomics.zig");
|
||||
|
||||
// macOS has these functions inside libSystem.
|
||||
if (builtin.cpu.arch.isAARCH64() and !builtin.os.tag.isDarwin()) {
|
||||
_ = @import("compiler_rt/aarch64_outline_atomics.zig");
|
||||
}
|
||||
|
||||
_ = @import("compiler_rt/addf3.zig");
|
||||
_ = @import("compiler_rt/addhf3.zig");
|
||||
_ = @import("compiler_rt/addsf3.zig");
|
||||
@ -216,9 +209,18 @@ comptime {
|
||||
_ = @import("compiler_rt/aullrem.zig");
|
||||
_ = @import("compiler_rt/clear_cache.zig");
|
||||
|
||||
_ = @import("compiler_rt/memcpy.zig");
|
||||
_ = @import("compiler_rt/memset.zig");
|
||||
_ = @import("compiler_rt/memmove.zig");
|
||||
_ = @import("compiler_rt/memcmp.zig");
|
||||
_ = @import("compiler_rt/bcmp.zig");
|
||||
if (@import("builtin").object_format != .c) {
|
||||
_ = @import("compiler_rt/atomics.zig");
|
||||
|
||||
// macOS has these functions inside libSystem.
|
||||
if (builtin.cpu.arch.isAARCH64() and !builtin.os.tag.isDarwin()) {
|
||||
_ = @import("compiler_rt/aarch64_outline_atomics.zig");
|
||||
}
|
||||
|
||||
_ = @import("compiler_rt/memcpy.zig");
|
||||
_ = @import("compiler_rt/memset.zig");
|
||||
_ = @import("compiler_rt/memmove.zig");
|
||||
_ = @import("compiler_rt/memcmp.zig");
|
||||
_ = @import("compiler_rt/bcmp.zig");
|
||||
}
|
||||
}
|
||||
|
@ -11,3 +11,4 @@ pub const value_tracing = false;
|
||||
pub const have_stage1 = false;
|
||||
pub const skip_non_native = false;
|
||||
pub const only_c = true;
|
||||
pub const force_gpa = false;
|
||||
|
677
stage1/zig1.c
677
stage1/zig1.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user