fix not using subtarget features

This commit is contained in:
Andrew Kelley 2015-11-24 15:01:37 -07:00
parent fefbee166d
commit baf5167171
6 changed files with 16 additions and 16 deletions

View File

@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) "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(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
set(ZIG_VERSION_MAJOR 0) set(ZIG_VERSION_MAJOR 0)
@ -40,14 +40,13 @@ configure_file (
${CONFIGURE_OUT_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}) add_executable(zig ${ZIG_SOURCES})
set_target_properties(zig PROPERTIES set_target_properties(zig PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXE_CFLAGS}) COMPILE_FLAGS ${EXE_CFLAGS})
target_link_libraries(zig LINK_PUBLIC target_link_libraries(zig LINK_PUBLIC
${LLVM_LIBRARIES} ${LLVM_LIBRARIES}

View File

@ -40,7 +40,6 @@ readable, safe, optimal, and concise code to solve any computing problem.
## Roadmap ## Roadmap
* Produce executable file instead of .o file.
* Add debugging symbols. * Add debugging symbols.
* Debug/Release mode. * Debug/Release mode.
* C style comments. * C style comments.

View File

@ -13,6 +13,8 @@
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#define BUF_INIT {{0}}
struct Buf { struct Buf {
ZigList<char> list; ZigList<char> list;
}; };

View File

@ -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, LLVMTargetMachineRef target_machine = LLVMCreateTargetMachine(target_ref, native_triple,
native_cpu, native_features, opt_level, reloc_mode, LLVMCodeModelDefault); 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_init_from_str(&out_file_o, out_file);
buf_append_str(&out_file_o, ".o"); buf_append_str(&out_file_o, ".o");

View File

@ -10,7 +10,8 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.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 line = token->start_line + 1;
int column = token->start_column + 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) { 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_buf_from_token(pc, token, &token_value);
ast_error(token, "invalid token: '%s'", buf_ptr(&token_value)); ast_error(token, "invalid token: '%s'", buf_ptr(&token_value));
} }

View File

@ -32,14 +32,13 @@ char *LLVMZigGetHostCPUName(void) {
} }
char *LLVMZigGetNativeFeatures(void) { char *LLVMZigGetNativeFeatures(void) {
return strdup(""); SubtargetFeatures features;
//SubtargetFeatures features;
//StringMap<bool> host_features; StringMap<bool> host_features;
//if (sys::getHostCPUFeatures(host_features)) { if (sys::getHostCPUFeatures(host_features)) {
// for (auto &F : host_features) for (auto &F : host_features)
// features.AddFeature(F.first(), F.second); features.AddFeature(F.first(), F.second);
//} }
//return strdup(features.getString().c_str()); return strdup(features.getString().c_str());
} }