2016-02-01 14:26:01 -08:00
|
|
|
cmake_minimum_required(VERSION 2.8.5)
|
2015-08-05 15:23:15 -07:00
|
|
|
|
2016-02-01 14:26:01 -08:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
|
|
|
|
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
|
|
|
endif()
|
2015-08-05 15:23:15 -07:00
|
|
|
|
2018-04-10 17:57:37 -07:00
|
|
|
if(NOT CMAKE_INSTALL_PREFIX)
|
2019-06-22 18:21:48 -07:00
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING
|
2018-04-10 17:57:37 -07:00
|
|
|
"Directory to install zig to" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2019-10-10 13:44:52 -07:00
|
|
|
set(CMAKE_USER_MAKE_RULES_OVERRIDE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_overrides.cmake)
|
|
|
|
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake)
|
|
|
|
|
2017-04-21 08:06:15 -07:00
|
|
|
project(zig C CXX)
|
2015-08-05 15:23:15 -07:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
|
|
|
|
2015-08-05 15:46:40 -07:00
|
|
|
set(ZIG_VERSION_MAJOR 0)
|
2019-09-30 07:09:33 -07:00
|
|
|
set(ZIG_VERSION_MINOR 5)
|
2018-03-15 06:15:05 -07:00
|
|
|
set(ZIG_VERSION_PATCH 0)
|
2015-08-05 15:23:15 -07:00
|
|
|
set(ZIG_VERSION "${ZIG_VERSION_MAJOR}.${ZIG_VERSION_MINOR}.${ZIG_VERSION_PATCH}")
|
2017-10-01 15:34:22 -07:00
|
|
|
|
|
|
|
find_program(GIT_EXE NAMES git)
|
|
|
|
if(GIT_EXE)
|
|
|
|
execute_process(
|
2018-06-29 19:22:04 -07:00
|
|
|
COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} name-rev HEAD --tags --name-only --no-undefined --always
|
2019-09-02 14:45:30 -07:00
|
|
|
RESULT_VARIABLE EXIT_STATUS
|
2017-10-01 15:34:22 -07:00
|
|
|
OUTPUT_VARIABLE ZIG_GIT_REV
|
2019-09-02 14:45:30 -07:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET)
|
|
|
|
if(EXIT_STATUS EQUAL "0")
|
|
|
|
if(ZIG_GIT_REV MATCHES "\\^0$")
|
|
|
|
if(NOT("${ZIG_GIT_REV}" STREQUAL "${ZIG_VERSION}^0"))
|
|
|
|
message("WARNING: Tag does not match configured Zig version")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(ZIG_VERSION "${ZIG_VERSION}+${ZIG_GIT_REV}")
|
2017-10-01 15:34:22 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-08-05 15:23:15 -07:00
|
|
|
message("Configuring zig version ${ZIG_VERSION}")
|
|
|
|
|
2018-03-30 10:20:13 -07:00
|
|
|
set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
|
2019-07-09 02:03:57 -07:00
|
|
|
set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
|
2019-09-25 22:57:34 -07:00
|
|
|
set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix")
|
add -DZIG_ENABLE_MEM_PROFILE option and -fmem-report flag
This can be used to find what's taking up memory in the compiler.
Here's an example of how to use it:
```
./zig test ../lib/std/std.zig --cache off -fmem-report
```
And here's the output I get for this on x86_64-linux-gnu today:
```
Const: 6462833 items, 152 bytes each, total 936.84 MiB
ConstGlobalRefs: 17236534 items, 24 bytes each, total 394.51 MiB
ResetResult: 1698108 items, 160 bytes each, total 259.11 MiB
ConstExprValue: 3118299 items, 80 bytes each, total 237.91 MiB
EndExpr: 1345395 items, 168 bytes each, total 215.56 MiB
Unknown_8: 27370821 items, 8 bytes each, total 208.82 MiB
VarPtr: 1127866 items, 168 bytes each, total 180.70 MiB
IrBasicBlock: 794834 items, 120 bytes each, total 90.96 MiB
LoadPtr: 554024 items, 160 bytes each, total 84.54 MiB
Unknown_64: 1245715 items, 64 bytes each, total 76.03 MiB
Unknown_40: 1879218 items, 40 bytes each, total 71.69 MiB
Unknown_72: 989117 items, 72 bytes each, total 67.92 MiB
Return: 423783 items, 160 bytes each, total 64.66 MiB
Unknown_168: 332480 items, 168 bytes each, total 53.27 MiB
Unknown_152: 336890 items, 152 bytes each, total 48.84 MiB
AddImplicitReturnType: 230819 items, 168 bytes each, total 36.98 MiB
Br: 217835 items, 168 bytes each, total 34.90 MiB
Unknown_184: 179529 items, 184 bytes each, total 31.50 MiB
FieldPtr: 179388 items, 184 bytes each, total 31.48 MiB
BinOp: 171004 items, 176 bytes each, total 28.70 MiB
LoadPtrGen: 173287 items, 168 bytes each, total 27.76 MiB
CondBr: 137864 items, 192 bytes each, total 25.24 MiB
Unknown_720: 30918 items, 720 bytes each, total 21.23 MiB
CallSrc: 99320 items, 216 bytes each, total 20.46 MiB
Unknown_160: 129243 items, 160 bytes each, total 19.72 MiB
Unknown_1: 19339456 items, 1 bytes each, total 18.44 MiB
CheckStatementIsVoid: 119838 items, 160 bytes each, total 18.29 MiB
Unknown_48: 371178 items, 48 bytes each, total 16.99 MiB
TestComptime: 101443 items, 160 bytes each, total 15.48 MiB
DeclVarSrc: 72578 items, 184 bytes each, total 12.74 MiB
StorePtr: 72776 items, 176 bytes each, total 12.22 MiB
ZigVar: 79201 items, 160 bytes each, total 12.09 MiB
Unknown_16: 770643 items, 16 bytes each, total 11.76 MiB
Phi: 60482 items, 184 bytes each, total 10.61 MiB
TestErrSrc: 66177 items, 168 bytes each, total 10.60 MiB
Unknown_240: 45164 items, 240 bytes each, total 10.34 MiB
ElemPtr: 58232 items, 184 bytes each, total 10.22 MiB
AllocaSrc: 60053 items, 176 bytes each, total 10.08 MiB
CallGen: 44873 items, 224 bytes each, total 9.59 MiB
SaveErrRetAddr: 63787 items, 152 bytes each, total 9.25 MiB
Unknown_112: 82283 items, 112 bytes each, total 8.79 MiB
AllocaGen: 51909 items, 176 bytes each, total 8.71 MiB
Unknown_24: 373599 items, 24 bytes each, total 8.55 MiB
ResultLocPeer: 113683 items, 72 bytes each, total 7.81 MiB
DeclRef: 36343 items, 168 bytes each, total 5.82 MiB
UnwrapErrPayload: 34603 items, 168 bytes each, total 5.54 MiB
Ref: 33414 items, 168 bytes each, total 5.35 MiB
Unknown_104: 53882 items, 104 bytes each, total 5.34 MiB
DeclVarGen: 32540 items, 168 bytes each, total 5.21 MiB
StructFieldPtr: 30449 items, 176 bytes each, total 5.11 MiB
UnwrapErrCode: 31508 items, 168 bytes each, total 5.05 MiB
Unknown_56: 90256 items, 56 bytes each, total 4.82 MiB
SpillBegin: 28722 items, 168 bytes each, total 4.60 MiB
SpillEnd: 28722 items, 160 bytes each, total 4.38 MiB
ResultLocReturn: 64573 items, 48 bytes each, total 2.96 MiB
PtrType: 14702 items, 184 bytes each, total 2.58 MiB
SliceType: 15005 items, 176 bytes each, total 2.52 MiB
Unknown_176: 13326 items, 176 bytes each, total 2.24 MiB
RefGen: 12881 items, 168 bytes each, total 2.06 MiB
UnOp: 12102 items, 176 bytes each, total 2.03 MiB
SwitchBr: 9453 items, 200 bytes each, total 1.80 MiB
TestErrGen: 11143 items, 160 bytes each, total 1.70 MiB
Unknown_32: 52359 items, 32 bytes each, total 1.60 MiB
CheckSwitchProngs: 9094 items, 184 bytes each, total 1.60 MiB
TypeOf: 9259 items, 160 bytes each, total 1.41 MiB
IntCast: 8772 items, 168 bytes each, total 1.41 MiB
OptionalUnwrapPtr: 8755 items, 168 bytes each, total 1.40 MiB
SwitchTarget: 9094 items, 160 bytes each, total 1.39 MiB
Cast: 8198 items, 176 bytes each, total 1.38 MiB
WidenOrShorten: 8448 items, 160 bytes each, total 1.29 MiB
ErrorUnion: 7613 items, 176 bytes each, total 1.28 MiB
SliceSrc: 6249 items, 192 bytes each, total 1.14 MiB
ErrWrapCode: 7133 items, 168 bytes each, total 1.14 MiB
TypeName: 7328 items, 160 bytes each, total 1.12 MiB
ImplicitCast: 5480 items, 176 bytes each, total 941.88 KiB
ResolveResult: 5638 items, 168 bytes each, total 924.98 KiB
ResultLocInstruction: 22696 items, 40 bytes each, total 886.56 KiB
BitCastSrc: 4947 items, 168 bytes each, total 811.62 KiB
CompileErr: 5148 items, 160 bytes each, total 804.38 KiB
ReturnPtr: 5305 items, 152 bytes each, total 787.46 KiB
Unreachable: 5038 items, 152 bytes each, total 747.83 KiB
TestNonNull: 4716 items, 160 bytes each, total 736.88 KiB
BitCastGen: 4431 items, 160 bytes each, total 692.34 KiB
PtrToInt: 4289 items, 160 bytes each, total 670.16 KiB
SliceGen: 3573 items, 192 bytes each, total 669.94 KiB
ArrayType: 4081 items, 168 bytes each, total 669.54 KiB
IntType: 3868 items, 168 bytes each, total 634.59 KiB
Unknown_88: 7213 items, 88 bytes each, total 619.87 KiB
Truncate: 3771 items, 168 bytes each, total 618.68 KiB
TypeInfo: 3740 items, 160 bytes each, total 584.38 KiB
SwitchVar: 3385 items, 176 bytes each, total 581.80 KiB
ContainerInitFields: 3223 items, 184 bytes each, total 579.13 KiB
ContainerInitList: 2309 items, 192 bytes each, total 432.94 KiB
PtrCastGen: 2626 items, 168 bytes each, total 430.83 KiB
BoolNot: 2457 items, 160 bytes each, total 383.91 KiB
FnProto: 2054 items, 184 bytes each, total 369.08 KiB
MergeErrSets: 1927 items, 176 bytes each, total 331.20 KiB
Unknown_136: 2486 items, 136 bytes each, total 330.17 KiB
Unknown_80: 4059 items, 80 bytes each, total 317.11 KiB
Bswap: 1670 items, 168 bytes each, total 273.98 KiB
TypeId: 1680 items, 160 bytes each, total 262.50 KiB
PtrCastSrc: 1371 items, 176 bytes each, total 235.64 KiB
ErrName: 1193 items, 160 bytes each, total 186.41 KiB
UnionTag: 1120 items, 160 bytes each, total 175.00 KiB
TagName: 1050 items, 160 bytes each, total 164.06 KiB
SizeOf: 942 items, 160 bytes each, total 147.19 KiB
MemberName: 871 items, 168 bytes each, total 142.90 KiB
Import: 881 items, 160 bytes each, total 137.66 KiB
PtrOfArrayToSlice: 758 items, 168 bytes each, total 124.36 KiB
UnionFieldPtr: 710 items, 176 bytes each, total 122.03 KiB
EnumToInt: 778 items, 160 bytes each, total 121.56 KiB
CheckRuntimeScope: 700 items, 168 bytes each, total 114.84 KiB
FieldParentPtr: 632 items, 184 bytes each, total 113.56 KiB
BoolToInt: 719 items, 160 bytes each, total 112.34 KiB
ResultLocPeerParent: 904 items, 104 bytes each, total 91.81 KiB
IntToPtr: 537 items, 168 bytes each, total 88.10 KiB
AlignOf: 561 items, 160 bytes each, total 87.66 KiB
AtomicRmw: 356 items, 208 bytes each, total 72.31 KiB
MemberCount: 441 items, 160 bytes each, total 68.91 KiB
Memset: 342 items, 176 bytes each, total 58.78 KiB
PopCount: 321 items, 168 bytes each, total 52.66 KiB
AlignCast: 251 items, 168 bytes each, total 41.18 KiB
IrInstruction *: 5230 items, 8 bytes each, total 40.86 KiB
IrBasicBlock *: 5230 items, 8 bytes each, total 40.86 KiB
TagType: 261 items, 160 bytes each, total 40.78 KiB
HasDecl: 234 items, 168 bytes each, total 38.39 KiB
OverflowOp: 191 items, 200 bytes each, total 37.30 KiB
Export: 209 items, 176 bytes each, total 35.92 KiB
SetCold: 219 items, 160 bytes each, total 34.22 KiB
ReturnAddress: 216 items, 152 bytes each, total 32.06 KiB
FromBytes: 178 items, 176 bytes each, total 30.59 KiB
SetRuntimeSafety: 188 items, 160 bytes each, total 29.38 KiB
OptionalWrap: 151 items, 168 bytes each, total 24.77 KiB
Clz: 143 items, 168 bytes each, total 23.46 KiB
ResizeSlice: 135 items, 168 bytes each, total 22.15 KiB
UnionInitNamedField: 106 items, 184 bytes each, total 19.05 KiB
Panic: 102 items, 160 bytes each, total 15.94 KiB
SwitchElseVar: 93 items, 168 bytes each, total 15.26 KiB
ToBytes: 89 items, 168 bytes each, total 14.60 KiB
IntToFloat: 78 items, 168 bytes each, total 12.80 KiB
Unknown_4360: 3 items, 4360 bytes each, total 12.77 KiB
ErrWrapPayload: 72 items, 168 bytes each, total 11.81 KiB
FloatOp: 62 items, 176 bytes each, total 10.66 KiB
FloatToInt: 47 items, 168 bytes each, total 7.71 KiB
FloatCast: 46 items, 168 bytes each, total 7.55 KiB
ErrToInt: 47 items, 160 bytes each, total 7.34 KiB
Asm: 33 items, 216 bytes each, total 6.96 KiB
ErrSetCast: 40 items, 168 bytes each, total 6.56 KiB
Memcpy: 34 items, 176 bytes each, total 5.84 KiB
AtomicLoad: 17 items, 184 bytes each, total 3.05 KiB
AwaitSrc: 16 items, 168 bytes each, total 2.62 KiB
Resume: 14 items, 160 bytes each, total 2.19 KiB
AwaitGen: 12 items, 176 bytes each, total 2.06 KiB
ArgType: 12 items, 168 bytes each, total 1.97 KiB
AnyFrameType: 12 items, 160 bytes each, total 1.88 KiB
SuspendFinish: 10 items, 160 bytes each, total 1.56 KiB
SuspendBegin: 10 items, 160 bytes each, total 1.56 KiB
Ctz: 9 items, 168 bytes each, total 1.48 KiB
FrameHandle: 8 items, 152 bytes each, total 1.19 KiB
SetEvalBranchQuota: 7 items, 160 bytes each, total 1.09 KiB
AssertZero: 7 items, 160 bytes each, total 1.09 KiB
UndeclaredIdent: 7 items, 160 bytes each, total 1.09 KiB
CmpxchgSrc: 5 items, 216 bytes each, total 1.05 KiB
CmpxchgGen: 5 items, 200 bytes each, total 1000.00 bytes
IntToEnum: 4 items, 168 bytes each, total 672.00 bytes
VectorType: 4 items, 168 bytes each, total 672.00 bytes
ErrorReturnTrace: 2 items, 160 bytes each, total 320.00 bytes
Breakpoint: 2 items, 152 bytes each, total 304.00 bytes
FrameAddress: 2 items, 152 bytes each, total 304.00 bytes
Unknown_4: 61 items, 4 bytes each, total 244.00 bytes
VectorToArray: 1 items, 168 bytes each, total 168.00 bytes
SetAlignStack: 1 items, 160 bytes each, total 160.00 bytes
Unknown_12: 2 items, 12 bytes each, total 24.00 bytes
ErrorTableEntry *: 0 items, 8 bytes each, total 0.00 bytes
AstNode *: 0 items, 8 bytes each, total 0.00 bytes
Total bytes used: 3.51 GiB
```
You can see that most of the memory is taken up by IR instructions,
as well as comptime values. This points toward 2 changes which will
greatly reduce memory usage:
* Rework semantic analysis so that IR instructions can be freed.
Currently the comptime value struct (ConstExprValue) is embedded
directly into the IrInstruction struct. If this is made to be
separate, at the very least pass 1 IR instructions can be freed.
This includes `Const` which is the largest usage of memory currently.
* Rework the ConstExprValue struct to no longer be a tagged union.
For example, there's no need for an integer comptime value to be
80 bytes.
From this you can also see that this eliminates some things from being
the culprit. Before doing this analysis, I considered whether doing
string interning would help. From the above output, you can see that all
strings in the compiler account for only 18 MiB, so string interning
would have been a dead end.
2019-10-19 00:23:23 -07:00
|
|
|
set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation")
|
2019-07-09 02:03:57 -07:00
|
|
|
|
|
|
|
if(ZIG_STATIC)
|
|
|
|
set(ZIG_STATIC_LLVM "on")
|
|
|
|
endif()
|
2016-02-11 00:33:27 -08:00
|
|
|
|
2017-10-01 13:10:05 -07:00
|
|
|
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}")
|
|
|
|
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_STATIC_LIB_DIR_ESCAPED "${ZIG_LIBC_STATIC_LIB_DIR}")
|
|
|
|
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_INCLUDE_DIR}")
|
2017-10-01 11:01:18 -07:00
|
|
|
|
2016-04-23 09:57:38 -07:00
|
|
|
option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
|
|
|
|
|
2017-08-28 00:12:23 -07:00
|
|
|
# To see what patches have been applied to LLD in this repository:
|
|
|
|
# git log -p -- deps/lld
|
|
|
|
option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead of the embedded LLD" OFF)
|
2016-02-11 00:33:27 -08:00
|
|
|
|
2017-09-12 21:17:19 -07:00
|
|
|
find_package(llvm)
|
|
|
|
find_package(clang)
|
2016-01-18 20:28:54 -08:00
|
|
|
|
2018-09-30 13:45:33 -07:00
|
|
|
if(APPLE AND ZIG_STATIC)
|
|
|
|
list(REMOVE_ITEM LLVM_LIBRARIES "-lz")
|
2018-03-20 04:46:31 -07:00
|
|
|
find_library(ZLIB NAMES z zlib libz)
|
2019-03-18 15:36:35 -07:00
|
|
|
list(APPEND LLVM_LIBRARIES "${ZLIB}")
|
2018-03-20 04:46:31 -07:00
|
|
|
endif()
|
|
|
|
|
2017-12-26 16:44:08 -08:00
|
|
|
set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zig_cpp")
|
|
|
|
|
2019-04-17 23:58:12 -07:00
|
|
|
# Handle multi-config builds and place each into a common lib. The VS generator
|
|
|
|
# for example will append a Debug folder by default if not explicitly specified.
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ZIG_CPP_LIB_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ZIG_CPP_LIB_DIR})
|
|
|
|
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
|
|
|
|
string(TOUPPER ${CONFIG_TYPE} CONFIG_TYPE)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${ZIG_CPP_LIB_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${ZIG_CPP_LIB_DIR})
|
|
|
|
endforeach(CONFIG_TYPE CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
2017-08-28 00:12:23 -07:00
|
|
|
if(ZIG_FORCE_EXTERNAL_LLD)
|
|
|
|
find_package(lld)
|
2017-12-01 10:44:28 -08:00
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
2017-08-28 00:12:23 -07:00
|
|
|
include_directories(${LLD_INCLUDE_DIRS})
|
2017-12-01 10:44:28 -08:00
|
|
|
include_directories(${CLANG_INCLUDE_DIRS})
|
2017-08-28 00:12:23 -07:00
|
|
|
else()
|
2017-12-01 10:44:28 -08:00
|
|
|
# This goes first so that we find embedded LLD instead
|
|
|
|
# of system LLD.
|
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/deps/lld/include")
|
|
|
|
|
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
include_directories(${CLANG_INCLUDE_DIRS})
|
2017-08-28 00:12:23 -07:00
|
|
|
set(EMBEDDED_LLD_LIB_SOURCES
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Args.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/ErrorHandler.cpp"
|
2019-08-03 09:43:55 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Filesystem.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Memory.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Reproduce.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Strings.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/TargetOptionsCommandFlags.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Threads.cpp"
|
2018-08-04 15:09:19 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Timer.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/Common/Version.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/DefinedAtom.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/Error.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/File.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/LinkingContext.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/Reader.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/Resolver.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/SymbolTable.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Core/Writer.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Driver/DarwinLdDriver.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/FileArchive.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ArchHandler.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/GOTPass.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/LayoutPass.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ObjCPass.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/ShimPass.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/StubsPass.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/TLVPass.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/MachO/WriterMachO.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
)
|
2019-02-07 14:07:18 -08:00
|
|
|
|
2017-08-28 00:12:23 -07:00
|
|
|
set(EMBEDDED_LLD_ELF_SOURCES
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/AArch64ErrataFix.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/AArch64.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/AMDGPU.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/ARM.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/AVR.cpp"
|
2018-08-04 15:09:19 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/Hexagon.cpp"
|
2019-02-07 14:07:18 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/MSP430.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/Mips.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/MipsArchTree.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/PPC.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/PPC64.cpp"
|
2019-02-07 14:07:18 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/RISCV.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/SPARCV9.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/X86.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Arch/X86_64.cpp"
|
2018-08-04 15:09:19 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/CallGraphSort.cpp"
|
2019-02-07 14:07:18 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/DWARF.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Driver.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/DriverUtils.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/EhFrame.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/ICF.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/InputFiles.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/InputSection.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/LTO.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/LinkerScript.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/MapFile.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/MarkLive.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/OutputSections.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Relocations.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/ScriptLexer.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/ScriptParser.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/SymbolTable.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Symbols.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/SyntheticSections.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Target.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Thunks.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF/Writer.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
)
|
2018-01-17 14:29:21 -08:00
|
|
|
|
2017-08-28 00:12:23 -07:00
|
|
|
set(EMBEDDED_LLD_COFF_SOURCES
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/Chunks.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/DLL.cpp"
|
2019-08-03 09:43:55 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/DebugTypes.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/Driver.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/DriverUtils.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/ICF.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/InputFiles.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/LTO.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/MapFile.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/MarkLive.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/MinGW.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/PDB.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/SymbolTable.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/Symbols.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF/Writer.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
)
|
|
|
|
set(EMBEDDED_LLD_MINGW_SOURCES
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/MinGW/Driver.cpp"
|
|
|
|
)
|
|
|
|
set(EMBEDDED_LLD_WASM_SOURCES
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/Driver.cpp"
|
2018-08-04 15:09:19 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/InputChunks.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/InputFiles.cpp"
|
2018-08-04 15:09:19 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/LTO.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/MarkLive.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/OutputSections.cpp"
|
2019-08-03 09:43:55 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/Relocations.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/SymbolTable.cpp"
|
2018-08-04 15:09:19 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/Symbols.cpp"
|
2019-08-03 09:43:55 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/SyntheticSections.cpp"
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/Writer.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm/WriterUtils.cpp"
|
2017-08-28 00:12:23 -07:00
|
|
|
)
|
2019-08-15 11:34:52 -07:00
|
|
|
add_library(embedded_lld_lib STATIC ${EMBEDDED_LLD_LIB_SOURCES})
|
|
|
|
add_library(embedded_lld_elf STATIC ${EMBEDDED_LLD_ELF_SOURCES})
|
|
|
|
add_library(embedded_lld_coff STATIC ${EMBEDDED_LLD_COFF_SOURCES})
|
|
|
|
add_library(embedded_lld_mingw STATIC ${EMBEDDED_LLD_MINGW_SOURCES})
|
|
|
|
add_library(embedded_lld_wasm STATIC ${EMBEDDED_LLD_WASM_SOURCES})
|
2017-09-12 21:17:19 -07:00
|
|
|
if(MSVC)
|
2017-10-16 06:10:20 -07:00
|
|
|
set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -D_CRT_SECURE_NO_WARNINGS /w")
|
2017-09-12 21:17:19 -07:00
|
|
|
else()
|
2019-04-24 07:56:16 -07:00
|
|
|
set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Wno-comment")
|
2018-09-29 23:34:38 -07:00
|
|
|
if(MINGW)
|
2019-07-26 14:26:01 -07:00
|
|
|
set(ZIG_LLD_COMPILE_FLAGS "${ZIG_LLD_COMPILE_FLAGS} -D__STDC_FORMAT_MACROS -D__USE_MINGW_ANSI_STDIO")
|
2018-09-29 23:34:38 -07:00
|
|
|
endif()
|
2017-09-10 13:05:18 -07:00
|
|
|
endif()
|
2017-08-28 00:12:23 -07:00
|
|
|
set_target_properties(embedded_lld_lib PROPERTIES
|
2017-09-12 21:17:19 -07:00
|
|
|
COMPILE_FLAGS ${ZIG_LLD_COMPILE_FLAGS}
|
2017-08-28 00:12:23 -07:00
|
|
|
LINK_FLAGS " "
|
|
|
|
)
|
|
|
|
set_target_properties(embedded_lld_elf PROPERTIES
|
2017-09-12 21:17:19 -07:00
|
|
|
COMPILE_FLAGS ${ZIG_LLD_COMPILE_FLAGS}
|
2017-08-28 00:12:23 -07:00
|
|
|
LINK_FLAGS " "
|
|
|
|
)
|
|
|
|
set_target_properties(embedded_lld_coff PROPERTIES
|
2017-09-12 21:17:19 -07:00
|
|
|
COMPILE_FLAGS ${ZIG_LLD_COMPILE_FLAGS}
|
2017-08-28 00:12:23 -07:00
|
|
|
LINK_FLAGS " "
|
|
|
|
)
|
2018-01-17 14:29:21 -08:00
|
|
|
set_target_properties(embedded_lld_mingw PROPERTIES
|
|
|
|
COMPILE_FLAGS ${ZIG_LLD_COMPILE_FLAGS}
|
|
|
|
LINK_FLAGS " "
|
|
|
|
)
|
|
|
|
set_target_properties(embedded_lld_wasm PROPERTIES
|
|
|
|
COMPILE_FLAGS ${ZIG_LLD_COMPILE_FLAGS}
|
|
|
|
LINK_FLAGS " "
|
|
|
|
)
|
2018-02-02 06:49:31 -08:00
|
|
|
target_include_directories(embedded_lld_lib PRIVATE
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt"
|
|
|
|
)
|
2018-02-02 06:49:31 -08:00
|
|
|
target_include_directories(embedded_lld_elf PRIVATE
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/ELF"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt/ELF"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt"
|
|
|
|
)
|
2018-02-02 06:49:31 -08:00
|
|
|
target_include_directories(embedded_lld_coff PRIVATE
|
2017-08-28 00:12:23 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/COFF"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt/COFF"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt"
|
|
|
|
)
|
2018-02-07 14:27:30 -08:00
|
|
|
target_include_directories(embedded_lld_mingw PRIVATE
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/MinGW"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt/MinGW"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt"
|
|
|
|
)
|
2018-02-07 14:27:30 -08:00
|
|
|
target_include_directories(embedded_lld_wasm PRIVATE
|
2018-01-17 14:29:21 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/wasm"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt/wasm"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/lld-prebuilt"
|
|
|
|
)
|
2017-08-28 00:12:23 -07:00
|
|
|
set(LLD_INCLUDE_DIRS "")
|
|
|
|
set(LLD_LIBRARIES
|
|
|
|
embedded_lld_elf
|
|
|
|
embedded_lld_coff
|
2018-01-17 14:29:21 -08:00
|
|
|
embedded_lld_mingw
|
|
|
|
embedded_lld_wasm
|
2017-08-28 00:34:50 -07:00
|
|
|
embedded_lld_lib
|
2017-08-28 00:12:23 -07:00
|
|
|
)
|
|
|
|
endif()
|
2017-03-13 08:54:56 -07:00
|
|
|
|
2018-03-09 12:06:06 -08:00
|
|
|
# No patches have been applied to SoftFloat-3e
|
2017-09-13 22:44:22 -07:00
|
|
|
set(EMBEDDED_SOFTFLOAT_SOURCES
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c"
|
2018-06-27 07:20:04 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c"
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c"
|
2018-06-27 07:20:04 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c"
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c"
|
2018-06-27 07:20:04 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c"
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_add.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_div.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_eq.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_eq_signaling.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_le.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_le_quiet.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_lt.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_lt_quiet.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mul.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mulAdd.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_rem.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_roundToInt.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_sqrt.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_sub.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i64_r_minMag.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c"
|
2018-06-27 07:20:04 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_add.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_div.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_eq.c"
|
2019-04-04 19:07:15 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_isSignalingNaN.c"
|
2018-06-27 07:20:04 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_lt.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_mul.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_rem.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_roundToInt.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_sqrt.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_sub.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_f128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_f64.c"
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f32_to_f128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f128M.c"
|
2018-06-27 07:20:04 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f16.c"
|
2019-03-22 11:56:03 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/i32_to_f128M.c"
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_add256M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addCarryM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addComplCarryM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecip32_1.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecipSqrt32_1.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecipSqrt_1Ks.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecip_1Ks.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare96M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros8.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_eq128.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_invalidF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_isNaNF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_le128.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_lt128.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mul128MTo256M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mul64To128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_negXM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF128SigM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF16Sig.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF32Sig.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF64Sig.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_remStepMBy32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToI64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToUI64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackMToF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToI32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToI64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToUI32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToUI64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftLeftM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftNormSigF128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJam256M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJam32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJam64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJamM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftLeft64To96M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftLeftM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightExtendM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightJam64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightJamM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_sub1XM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_sub256M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subM.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF16.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF32.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF64.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c"
|
2019-06-18 15:28:49 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_mulAdd.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mulAdd.c"
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/softfloat_state.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui32_to_f128M.c"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui64_to_f128M.c"
|
2017-09-13 22:44:22 -07:00
|
|
|
)
|
2019-08-15 11:34:52 -07:00
|
|
|
add_library(embedded_softfloat STATIC ${EMBEDDED_SOFTFLOAT_SOURCES})
|
2017-09-13 22:44:22 -07:00
|
|
|
if(MSVC)
|
|
|
|
set_target_properties(embedded_softfloat PROPERTIES
|
2017-10-16 06:10:20 -07:00
|
|
|
COMPILE_FLAGS "-std=c99 /w"
|
2017-09-13 22:44:22 -07:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
set_target_properties(embedded_softfloat PROPERTIES
|
2018-09-10 06:46:15 -07:00
|
|
|
COMPILE_FLAGS "-std=c99 -O3"
|
2017-09-13 22:44:22 -07:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
target_include_directories(embedded_softfloat PUBLIC
|
2018-03-09 12:06:06 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e-prebuilt"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086"
|
2015-08-05 15:46:40 -07:00
|
|
|
)
|
2018-03-09 12:06:06 -08:00
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/include")
|
2017-09-13 22:44:22 -07:00
|
|
|
set(SOFTFLOAT_LIBRARIES embedded_softfloat)
|
|
|
|
|
|
|
|
find_package(Threads)
|
2015-08-05 15:46:40 -07:00
|
|
|
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
# CMake doesn't let us create an empty executable, so we hang on to this one separately.
|
|
|
|
set(ZIG_MAIN_SRC "${CMAKE_SOURCE_DIR}/src/main.cpp")
|
|
|
|
|
|
|
|
# This is our shim which will be replaced by libuserland written in Zig.
|
2019-04-17 11:09:18 -07:00
|
|
|
set(ZIG0_SHIM_SRC "${CMAKE_SOURCE_DIR}/src/userland.cpp")
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
|
2019-11-24 12:29:43 -08:00
|
|
|
if(ZIG_ENABLE_MEM_PROFILE)
|
|
|
|
set(ZIG_SOURCES_MEM_PROFILE "${CMAKE_SOURCE_DIR}/src/memory_profiling.cpp")
|
|
|
|
endif()
|
|
|
|
|
2015-08-05 15:23:15 -07:00
|
|
|
set(ZIG_SOURCES
|
2016-09-29 23:21:21 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/analyze.cpp"
|
2016-01-27 20:10:38 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/ast_render.cpp"
|
2017-06-26 11:41:47 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/bigfloat.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/bigint.cpp"
|
2016-09-29 23:21:21 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/buffer.cpp"
|
2016-04-21 15:48:13 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/c_tokenizer.cpp"
|
2018-09-10 06:46:15 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/cache_hash.cpp"
|
2015-11-30 18:58:53 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/codegen.cpp"
|
2018-09-10 14:30:45 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/compiler.cpp"
|
2019-10-03 14:58:22 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/dump_analysis.cpp"
|
2016-09-29 23:21:21 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/errmsg.cpp"
|
2015-11-04 23:05:25 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/error.cpp"
|
2019-07-21 13:21:16 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/glibc.cpp"
|
2016-12-18 13:56:50 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/ir.cpp"
|
2016-09-30 17:12:00 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/ir_print.cpp"
|
2019-02-23 06:35:56 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/libc_installation.cpp"
|
2016-09-29 23:21:21 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/link.cpp"
|
2015-11-30 18:58:53 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/os.cpp"
|
2016-09-29 23:21:21 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/parser.cpp"
|
2017-05-07 09:07:35 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/range_set.cpp"
|
2016-09-29 23:21:21 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/target.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/tokenizer.cpp"
|
2017-11-24 11:56:05 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/translate_c.cpp"
|
2019-03-22 11:56:03 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/util.cpp"
|
2019-11-24 12:29:43 -08:00
|
|
|
"${ZIG_SOURCES_MEM_PROFILE}"
|
2017-12-26 16:44:08 -08:00
|
|
|
)
|
2019-03-22 11:56:03 -07:00
|
|
|
set(OPTIMIZED_C_SOURCES
|
2018-09-11 14:29:18 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/blake2b.c"
|
2019-03-22 11:56:03 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/parse_f128.c"
|
2018-09-10 06:46:15 -07:00
|
|
|
)
|
2017-12-26 16:44:08 -08:00
|
|
|
set(ZIG_CPP_SOURCES
|
2015-11-24 12:00:38 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/zig_llvm.cpp"
|
2019-02-16 12:14:51 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/zig_clang.cpp"
|
2019-02-24 09:53:28 -08:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/zig_clang_driver.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/zig_clang_cc1_main.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/zig_clang_cc1as_main.cpp"
|
2018-07-20 20:37:37 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/windows_sdk.cpp"
|
2015-08-05 15:23:15 -07:00
|
|
|
)
|
|
|
|
|
2018-01-04 19:46:26 -08:00
|
|
|
if(MSVC)
|
|
|
|
set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
|
2019-06-22 18:21:48 -07:00
|
|
|
if(IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
|
2018-01-04 19:46:26 -08:00
|
|
|
set(ZIG_DIA_GUIDS_LIB "${MSVC_DIA_SDK_DIR}/lib/amd64/diaguids.lib")
|
|
|
|
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_DIA_GUIDS_LIB_ESCAPED "${ZIG_DIA_GUIDS_LIB}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-10-01 15:29:50 -07:00
|
|
|
set(ZIG_LIB_DIR "lib/zig")
|
|
|
|
set(C_HEADERS_DEST "${ZIG_LIB_DIR}/include")
|
2019-03-04 19:15:53 -08:00
|
|
|
set(LIBC_FILES_DEST "${ZIG_LIB_DIR}/libc")
|
2019-03-05 19:45:41 -08:00
|
|
|
set(LIBUNWIND_FILES_DEST "${ZIG_LIB_DIR}/libunwind")
|
|
|
|
set(LIBCXX_FILES_DEST "${ZIG_LIB_DIR}/libcxx")
|
2017-10-01 15:29:50 -07:00
|
|
|
set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")
|
2015-08-05 15:23:15 -07:00
|
|
|
configure_file (
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/config.h.in"
|
2019-03-12 14:32:32 -07:00
|
|
|
"${CMAKE_BINARY_DIR}/config.h"
|
2015-08-05 15:23:15 -07:00
|
|
|
)
|
|
|
|
|
2015-11-26 00:29:52 -08:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_SOURCE_DIR}
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
"${CMAKE_SOURCE_DIR}/src"
|
|
|
|
)
|
|
|
|
|
2018-09-05 09:10:53 -07:00
|
|
|
# These have to go before the -Wno- flags
|
|
|
|
set(EXE_CFLAGS "-std=c++11")
|
2018-09-05 07:18:12 -07:00
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
|
|
|
if(MSVC)
|
|
|
|
set(EXE_CFLAGS "${EXE_CFLAGS} /w")
|
|
|
|
else()
|
|
|
|
set(EXE_CFLAGS "${EXE_CFLAGS} -Werror -Wall")
|
|
|
|
endif()
|
2016-02-16 19:34:45 -08:00
|
|
|
endif()
|
|
|
|
|
2017-09-12 21:17:19 -07:00
|
|
|
if(MSVC)
|
2019-06-22 18:21:48 -07:00
|
|
|
set(EXE_CFLAGS "${EXE_CFLAGS}")
|
2017-09-12 21:17:19 -07:00
|
|
|
else()
|
2019-09-06 14:03:34 -07:00
|
|
|
set(EXE_CFLAGS "${EXE_CFLAGS} -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Werror=type-limits -Wno-missing-braces")
|
2019-06-22 18:21:48 -07:00
|
|
|
if(MINGW)
|
|
|
|
set(EXE_CFLAGS "${EXE_CFLAGS} -Wno-format")
|
|
|
|
endif()
|
2017-09-10 13:05:18 -07:00
|
|
|
endif()
|
2017-09-12 21:17:19 -07:00
|
|
|
|
2019-03-22 11:56:03 -07:00
|
|
|
set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
|
2018-09-05 07:18:12 -07:00
|
|
|
|
2016-04-23 09:57:38 -07:00
|
|
|
set(EXE_LDFLAGS " ")
|
2019-03-26 22:54:46 -07:00
|
|
|
if(MSVC)
|
2019-07-26 14:26:01 -07:00
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} /STACK:16777216")
|
2019-09-08 03:07:23 -07:00
|
|
|
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT "${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
|
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} /debug:fastlink")
|
|
|
|
endif()
|
2019-06-22 23:15:04 -07:00
|
|
|
elseif(MINGW)
|
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZIG_STATIC)
|
2018-09-27 12:07:51 -07:00
|
|
|
if(APPLE)
|
2019-07-26 14:26:01 -07:00
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++")
|
2019-07-13 15:44:05 -07:00
|
|
|
elseif(MINGW)
|
2019-07-26 14:26:01 -07:00
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} -static-libgcc -static-libstdc++ -Wl,-Bstatic, -lwinpthread -lz3 -lz -lgomp")
|
2019-07-27 15:54:20 -07:00
|
|
|
elseif(NOT MSVC)
|
2019-07-26 14:26:01 -07:00
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} -static")
|
2018-09-27 12:07:51 -07:00
|
|
|
endif()
|
2019-07-26 14:26:01 -07:00
|
|
|
else()
|
|
|
|
if(MINGW)
|
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")
|
|
|
|
endif()
|
2017-09-23 15:46:03 -07:00
|
|
|
endif()
|
2019-06-22 23:15:04 -07:00
|
|
|
|
2016-04-23 09:57:38 -07:00
|
|
|
if(ZIG_TEST_COVERAGE)
|
|
|
|
set(EXE_CFLAGS "${EXE_CFLAGS} -fprofile-arcs -ftest-coverage")
|
2017-09-23 15:46:03 -07:00
|
|
|
set(EXE_LDFLAGS "${EXE_LDFLAGS} -fprofile-arcs -ftest-coverage")
|
2016-04-23 09:57:38 -07:00
|
|
|
endif()
|
2015-08-05 15:23:15 -07:00
|
|
|
|
2017-12-26 16:44:08 -08:00
|
|
|
add_library(zig_cpp STATIC ${ZIG_CPP_SOURCES})
|
2017-12-26 17:04:09 -08:00
|
|
|
set_target_properties(zig_cpp PROPERTIES
|
|
|
|
COMPILE_FLAGS ${EXE_CFLAGS}
|
|
|
|
)
|
2017-12-26 16:44:08 -08:00
|
|
|
|
2019-03-22 11:56:03 -07:00
|
|
|
add_library(opt_c_util STATIC ${OPTIMIZED_C_SOURCES})
|
|
|
|
set_target_properties(opt_c_util PROPERTIES
|
|
|
|
COMPILE_FLAGS "${OPTIMIZED_C_FLAGS}"
|
2018-09-10 06:46:15 -07:00
|
|
|
)
|
|
|
|
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
add_library(compiler STATIC ${ZIG_SOURCES})
|
|
|
|
set_target_properties(compiler PROPERTIES
|
2016-04-23 09:57:38 -07:00
|
|
|
COMPILE_FLAGS ${EXE_CFLAGS}
|
|
|
|
LINK_FLAGS ${EXE_LDFLAGS}
|
|
|
|
)
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
target_link_libraries(compiler LINK_PUBLIC
|
2017-12-26 16:44:08 -08:00
|
|
|
zig_cpp
|
2019-03-22 11:56:03 -07:00
|
|
|
opt_c_util
|
2017-09-13 22:44:22 -07:00
|
|
|
${SOFTFLOAT_LIBRARIES}
|
2016-01-26 23:01:49 -08:00
|
|
|
${CLANG_LIBRARIES}
|
2017-03-13 08:54:56 -07:00
|
|
|
${LLD_LIBRARIES}
|
2016-02-01 21:38:55 -08:00
|
|
|
${LLVM_LIBRARIES}
|
2017-03-29 22:18:12 -07:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
2015-08-05 15:23:15 -07:00
|
|
|
)
|
2018-03-10 15:23:08 -08:00
|
|
|
if(NOT MSVC)
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
target_link_libraries(compiler LINK_PUBLIC ${LIBXML2})
|
2018-03-10 11:48:41 -08:00
|
|
|
endif()
|
2019-03-09 15:54:34 -08:00
|
|
|
|
2018-01-04 19:46:26 -08:00
|
|
|
if(ZIG_DIA_GUIDS_LIB)
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
target_link_libraries(compiler LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})
|
2018-01-04 19:46:26 -08:00
|
|
|
endif()
|
|
|
|
|
2017-09-13 22:44:22 -07:00
|
|
|
if(MSVC OR MINGW)
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
target_link_libraries(compiler LINK_PUBLIC version)
|
|
|
|
endif()
|
|
|
|
|
2019-04-17 11:09:18 -07:00
|
|
|
add_executable(zig0 "${ZIG_MAIN_SRC}" "${ZIG0_SHIM_SRC}")
|
|
|
|
set_target_properties(zig0 PROPERTIES
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
COMPILE_FLAGS ${EXE_CFLAGS}
|
|
|
|
LINK_FLAGS ${EXE_LDFLAGS}
|
|
|
|
)
|
2019-04-17 11:09:18 -07:00
|
|
|
target_link_libraries(zig0 compiler)
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
|
2019-07-12 16:28:28 -07:00
|
|
|
if(MSVC)
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.lib")
|
|
|
|
else()
|
|
|
|
set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")
|
2017-09-10 13:05:18 -07:00
|
|
|
endif()
|
2019-09-09 06:33:33 -07:00
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
|
|
|
set(LIBUSERLAND_RELEASE_MODE "false")
|
|
|
|
else()
|
|
|
|
set(LIBUSERLAND_RELEASE_MODE "true")
|
|
|
|
endif()
|
2019-09-25 22:57:34 -07:00
|
|
|
if(ZIG_SKIP_INSTALL_LIB_FILES)
|
|
|
|
set(ZIG_BUILD_INSTALL_STEP "")
|
|
|
|
else()
|
|
|
|
set(ZIG_BUILD_INSTALL_STEP "install")
|
|
|
|
endif()
|
2019-07-14 00:06:20 -07:00
|
|
|
add_custom_target(zig_build_libuserland ALL
|
|
|
|
COMMAND zig0 build
|
2019-09-25 20:57:47 -07:00
|
|
|
--override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
2019-09-25 22:57:34 -07:00
|
|
|
libuserland ${ZIG_BUILD_INSTALL_STEP}
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
"-Doutput-dir=${CMAKE_BINARY_DIR}"
|
2019-09-09 06:33:33 -07:00
|
|
|
"-Drelease=${LIBUSERLAND_RELEASE_MODE}"
|
2019-07-14 00:06:20 -07:00
|
|
|
"-Dlib-files-only"
|
|
|
|
--prefix "${CMAKE_INSTALL_PREFIX}"
|
|
|
|
DEPENDS zig0
|
|
|
|
BYPRODUCTS "${LIBUSERLAND}"
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
)
|
|
|
|
add_executable(zig "${ZIG_MAIN_SRC}")
|
2019-07-12 16:28:28 -07:00
|
|
|
|
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
2019-04-16 13:47:47 -07:00
|
|
|
set_target_properties(zig PROPERTIES
|
|
|
|
COMPILE_FLAGS ${EXE_CFLAGS}
|
|
|
|
LINK_FLAGS ${EXE_LDFLAGS}
|
|
|
|
)
|
|
|
|
target_link_libraries(zig compiler "${LIBUSERLAND}")
|
2019-10-21 16:17:33 -07:00
|
|
|
if(MSVC)
|
|
|
|
target_link_libraries(zig ntdll.lib)
|
2019-10-22 17:34:34 -07:00
|
|
|
elseif(MINGW)
|
|
|
|
target_link_libraries(zig ntdll)
|
2019-10-21 16:17:33 -07:00
|
|
|
endif()
|
2019-07-14 19:29:31 -07:00
|
|
|
add_dependencies(zig zig_build_libuserland)
|
2015-08-05 15:23:15 -07:00
|
|
|
install(TARGETS zig DESTINATION bin)
|