Skip to content

Commit

Permalink
Compiling does not leave exe when successful, and also works with gen…
Browse files Browse the repository at this point in the history
…eric modules. #1027. For now, silence errors due to the macos linker changes. #1028. Try update `clean` on Windows #456.
  • Loading branch information
lerno committed Oct 5, 2023
1 parent 70f906c commit a07ba63
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/build/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ typedef enum
ARCH_OS_TARGET_LAST = WINDOWS_X64
} ArchOsTarget;

#define ANY_WINDOWS_ARCH_OS WINDOWS_AARCH64: case WINDOWS_X64: case MINGW_X64

typedef struct BuildOptions_
{
const char *lib_dir[MAX_LIB_DIRS];
Expand Down
7 changes: 3 additions & 4 deletions src/compiler/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,7 @@ const char *get_object_extension(void)
{
switch (active_target.arch_os_target)
{
case WINDOWS_X64:
case WINDOWS_AARCH64:
case MINGW_X64:
case ANY_WINDOWS_ARCH_OS:
return ".obj";
default:
return ".o";
Expand Down Expand Up @@ -1045,7 +1043,7 @@ File *compile_and_invoke(const char *file, const char *args)
#else
const char *output = "__c3exec__";
#endif
scratch_buffer_append(" compile");
scratch_buffer_append(" compile -g0 --single-module=yes");
StringSlice slice = slice_from_string(file);
while (slice.len > 0)
{
Expand All @@ -1072,6 +1070,7 @@ File *compile_and_invoke(const char *file, const char *args)
{
error_exit("Error invoking script '%s' with arguments %s.", file, args);
}
file_delete_file(output);
return source_file_text_load(file, out);
}

Expand Down
1 change: 1 addition & 0 deletions src/compiler/compiler_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,7 @@ INLINE const char *section_from_id(SectionId id);
Module *compiler_find_or_create_module(Path *module_name, const char **parameters);
Module *global_context_find_module(const char *name);
const char *get_object_extension(void);
const char *get_exe_extension(void);

CompilationUnit * unit_create(File *file);
void unit_register_global_decl(CompilationUnit *unit, Decl *decl);
Expand Down
1 change: 1 addition & 0 deletions src/compiler/linker.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ static void linker_setup_macos(const char ***args_ref, LinkerType linker_type)
add_arg("CoreFoundation");
if (linker_type == LINKER_CC)
{
add_arg("-ld_classic");
return;
}
add_arg("-arch");
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/semantic_analyser.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls)
case DECL_DECLARRAY:
case DECL_ERASED:
case DECL_FNTYPE:
case DECL_CT_INCLUDE:
case DECL_CT_EXEC:
continue;
case DECL_ATTRIBUTE:
break;
case DECL_BODYPARAM:
case DECL_CT_INCLUDE:
case DECL_CT_EXEC:
case DECL_GLOBALS:
UNREACHABLE
case DECL_MACRO:
Expand Down
6 changes: 3 additions & 3 deletions src/utils/file_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ bool file_delete_all_files_in_dir_with_suffix(const char *path, const char *suff
{
assert(path);
#if (_MSC_VER)
const char *cmd = "del /q";
const char *cmd = "del /q %s\\*%s";
#else
const char *cmd = "rm -f";
const char *cmd = "rm -f %s/*%s";
#endif
return execute_cmd(str_printf("%s %s/*%s", cmd, path, suffix)) == 0;
return execute_cmd(str_printf(cmd, path, suffix)) == 0;
}

#if (_MSC_VER)
Expand Down

0 comments on commit a07ba63

Please sign in to comment.