Skip to content

Commit

Permalink
Fixed v2.6 issues on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacShelton committed Feb 12, 2022
1 parent 8089a57 commit bad7b99
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ UNIX_LLVM_BUILD_INCLUDE=
UNIX_LIBCURL_LIB=/opt/homebrew/opt/curl/lib
UNIX_LIBCURL_INCLUDE=/opt/homebrew/opt/curl/lib
UNIX_LIBCURL_BUILD_INCLUDE=
DEBUG_ADDRESS_SANITIZE=true
DEBUG_ADDRESS_SANITIZE=false
DEBUG_LEAK_SANITIZE=false
#UNIX_CC=gcc
#UNIX_CXX=g++
Expand Down Expand Up @@ -120,7 +120,7 @@ LLVM_INCLUDE_FLAGS=$(LLVM_INCLUDE_DIRS) -DNDEBUG -DLLVM_BUILD_GLOBAL_ISEL -D__ST
# -lgtest_main -lgtest -lLLVMTestingSupport

# -static-libgcc -static-libstdc++ -static
CFLAGS=-c -Wall -Wextra -I"include" $(LLVM_INCLUDE_FLAGS) $(LIBCURL_INCLUDE_FLAGS) -std=c11 -pedantic-errors -O0 -DNDEBUG -Werror -ferror-limit=1 # -fmax-errors=1 -Werror
CFLAGS=-c -Wall -Wextra -I"include" $(LLVM_INCLUDE_FLAGS) $(LIBCURL_INCLUDE_FLAGS) -std=gnu11 -pedantic-errors -O0 -DNDEBUG # -Werror -ferror-limit=1 # -fmax-errors=1 -Werror
ADDITIONAL_DEBUG_CFLAGS=-DENABLE_DEBUG_FEATURES -g

ifeq ($(ENABLE_ADEPT_PACKAGE_MANAGER),true)
Expand All @@ -139,6 +139,10 @@ ifeq ($(DEBUG_LEAK_SANITIZE),true)
LDFLAGS+= -fsanitize=leak
endif

ifeq ($(OS), Windows_NT)
CFLAGS+= -D__USE_MINGW_ANSI_STDIO
endif

ESSENTIAL_SOURCES= \
src/AST/EXPR/ast_expr_free.c src/AST/EXPR/ast_expr_str.c \
src/AST/TYPE/ast_type_clone.c src/AST/TYPE/ast_type_free.c \
Expand Down Expand Up @@ -347,6 +351,7 @@ endif
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
ifeq ($(OS), Windows_NT)
@if not exist obj mkdir obj
@if not exist obj\AST mkdir obj\AST
@if not exist obj\debug mkdir obj\debug
@if not exist "$(@D)" mkdir "$(@D)"
else
Expand Down
4 changes: 2 additions & 2 deletions src/BKEND/ir_to_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ static maybe_null_strong_cstr_t create_link_command_from_parts(llvm_context_t *l
#ifdef _WIN32
// Windows -> ???

if(compiler->cross_compile_for == CROSS_COMPILE_MACOS){
if(llvm->compiler->cross_compile_for == CROSS_COMPILE_MACOS){
// Windows -> MacOS
// Even though we can't link it,
// we will give the user the link command needed to link it on a MacOS machine.
return create_unix_link_command(compiler, "gcc", objfile_filename, linker_additional);
return create_unix_link_command(llvm->compiler, "gcc", objfile_filename, linker_additional);
}

// Windows -> Windows
Expand Down
2 changes: 1 addition & 1 deletion src/DRVR/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static successful_t config_read_adept_config_value(config_t *config, jsmnh_obj_c
// Since we are using binary file stream mode, don't rely on fprintf
time_t timestamp = time(NULL);
char timestamp_buffer[256];
sprintf(timestamp_buffer, "%"PRIu64, (uint64_t) timestamp);
sprintf(timestamp_buffer, "%zu", (uint64_t) timestamp);
fwrite(timestamp_buffer, 1, strlen(timestamp_buffer), f);

fwrite(buffer.content + last_update.end, 1, buffer.capacity - last_update.end, f);
Expand Down
4 changes: 2 additions & 2 deletions src/UTIL/jsmn_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ errorcode_t jsmnh_obj_ctx_easy_init(jsmnh_obj_ctx_t *ctx, char *raw_buffer, leng
jsmn_init(&parser);

// Try to precompute number of tokens needed
length_t required_tokens = jsmn_parse(&parser, raw_buffer, raw_buffer_length, NULL, 0);
int required_tokens = jsmn_parse(&parser, raw_buffer, raw_buffer_length, NULL, 0);
if(required_tokens < 0) return FAILURE;

// Preallocate enough space for tokens
Expand All @@ -60,7 +60,7 @@ errorcode_t jsmnh_obj_ctx_easy_init(jsmnh_obj_ctx_t *ctx, char *raw_buffer, leng
};

if(parse_error < 0
|| (int) required_tokens != parse_error
|| required_tokens != parse_error
|| !jsmnh_get_object(raw_buffer, tokens, 0)){
return FAILURE;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/winmain_entry/main.adept
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma windows_only
pragma ignore_unused

import 'sys/cstdio.adept'

Expand All @@ -17,6 +18,8 @@ bomb Bomb = Bomb('Hello World')
external stdcall func WinMain(hInstance, hPrevInstance HINSTANCE, lpCmdLine LPSTR, nCmdShow int) int {
// The initialization of 'bomb' and its automatic '__defer__' call should
// happen here implicitly

return 0
}

/*
Expand Down

0 comments on commit bad7b99

Please sign in to comment.