diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c60947973..88f22d13de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) -project(zig C CXX) +project(zig CXX) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) set(ZIG_VERSION_MAJOR 0) @@ -40,14 +40,13 @@ configure_file ( ${CONFIGURE_OUT_FILE} ) -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-unused-variable -Wno-unused-but-set-variable") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-unused-variable -Wno-unused-but-set-variable") -set(EXE_CFLAGS "-std=c++11 -Werror -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes") +set(EXE_CFLAGS "-std=c++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Werror -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes") add_executable(zig ${ZIG_SOURCES}) set_target_properties(zig PROPERTIES - LINKER_LANGUAGE C COMPILE_FLAGS ${EXE_CFLAGS}) target_link_libraries(zig LINK_PUBLIC ${LLVM_LIBRARIES} diff --git a/README.md b/README.md index 6c8611a366..675d364bab 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ readable, safe, optimal, and concise code to solve any computing problem. ## Roadmap - * Produce executable file instead of .o file. * Add debugging symbols. * Debug/Release mode. * C style comments. diff --git a/src/buffer.hpp b/src/buffer.hpp index 310093f16e..9f1ea9124c 100644 --- a/src/buffer.hpp +++ b/src/buffer.hpp @@ -13,6 +13,8 @@ #include #include +#define BUF_INIT {{0}} + struct Buf { ZigList list; }; diff --git a/src/codegen.cpp b/src/codegen.cpp index a9e7383321..0f0f32b82f 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -423,7 +423,7 @@ void code_gen_link(CodeGen *g, bool is_static, const char *out_file) { LLVMTargetMachineRef target_machine = LLVMCreateTargetMachine(target_ref, native_triple, native_cpu, native_features, opt_level, reloc_mode, LLVMCodeModelDefault); - Buf out_file_o = {0}; + Buf out_file_o = BUF_INIT; buf_init_from_str(&out_file_o, out_file); buf_append_str(&out_file_o, ".o"); diff --git a/src/parser.cpp b/src/parser.cpp index 9de20e9c9c..403cd9d9b2 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -10,7 +10,8 @@ #include #include -void ast_error(Token *token, const char *format, ...) { +__attribute__ ((format (printf, 2, 3))) +static void ast_error(Token *token, const char *format, ...) { int line = token->start_line + 1; int column = token->start_column + 1; @@ -221,7 +222,7 @@ static void parse_string_literal(ParseContext *pc, Token *token, Buf *buf) { } static void ast_invalid_token_error(ParseContext *pc, Token *token) { - Buf token_value = {0}; + Buf token_value = BUF_INIT; ast_buf_from_token(pc, token, &token_value); ast_error(token, "invalid token: '%s'", buf_ptr(&token_value)); } diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index 2f064a297b..a43e0a541b 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -32,14 +32,13 @@ char *LLVMZigGetHostCPUName(void) { } char *LLVMZigGetNativeFeatures(void) { - return strdup(""); - //SubtargetFeatures features; + SubtargetFeatures features; - //StringMap host_features; - //if (sys::getHostCPUFeatures(host_features)) { - // for (auto &F : host_features) - // features.AddFeature(F.first(), F.second); - //} + StringMap host_features; + if (sys::getHostCPUFeatures(host_features)) { + for (auto &F : host_features) + features.AddFeature(F.first(), F.second); + } - //return strdup(features.getString().c_str()); + return strdup(features.getString().c_str()); }