Commit baf5167171
Changed files (6)
src/buffer.hpp
@@ -13,6 +13,8 @@
#include <assert.h>
#include <stdint.h>
+#define BUF_INIT {{0}}
+
struct Buf {
ZigList<char> list;
};
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");
src/parser.cpp
@@ -10,7 +10,8 @@
#include <stdarg.h>
#include <stdio.h>
-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));
}
src/zig_llvm.cpp
@@ -32,14 +32,13 @@ char *LLVMZigGetHostCPUName(void) {
}
char *LLVMZigGetNativeFeatures(void) {
- return strdup("");
- //SubtargetFeatures features;
+ SubtargetFeatures features;
- //StringMap<bool> host_features;
- //if (sys::getHostCPUFeatures(host_features)) {
- // for (auto &F : host_features)
- // features.AddFeature(F.first(), F.second);
- //}
+ StringMap<bool> 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());
}
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}
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.