Skip to content

Commit

Permalink
Use global definition; fix preprocessor shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
chalcolith committed Oct 30, 2023
1 parent 8bd01f8 commit 44e02d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ if(NOT MSVC)
endif()
endif()

set(PONY_OSX_PLATFORM "13.0.0")
set(PONY_OSX_PLATFORM 13.0.0)

# LLVM component setup
if(NOT PONY_CROSS_LIBPONYRT)
Expand Down Expand Up @@ -227,6 +227,7 @@ add_compile_definitions(
$<$<CONFIG:Release>:PONY_VERSION_STR="${PONYC_VERSION} [release]\\nCompiled with: LLVM ${LLVM_VERSION} -- ${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}-${_compiler_arch}">
$<$<CONFIG:RelWithDebInfo>:PONY_VERSION_STR="${PONYC_VERSION} [relwithdebinfo]\\nCompiled with: LLVM ${LLVM_VERSION} -- ${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}-${_compiler_arch}">
$<$<CONFIG:MinSizeRel>:PONY_VERSION_STR="${PONYC_VERSION} [minsizerel]\\nCompiled with: LLVM ${LLVM_VERSION} -- ${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}-${_compiler_arch}">
PONY_OSX_PLATFORM=${PONY_OSX_PLATFORM}
)

include(CheckIPOSupported)
Expand Down
1 change: 0 additions & 1 deletion src/libponyc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ target_include_directories(libponyc

if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${PONY_OSX_PLATFORM})
target_compile_definitions(libponyc PUBLIC PONY_OSX_PLATFORM=${PONY_OSX_PLATFORM})
endif()

if (MSVC)
Expand Down
7 changes: 4 additions & 3 deletions src/libponyc/codegen/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include <llvm-c/Support.h>
#include <string.h>

#define STRINGIFY(x) #x
#define STR(x) STR2(x)
#define STR2(x) #x

struct compile_local_t
{
Expand Down Expand Up @@ -822,10 +823,10 @@ bool codegen_pass_init(pass_opt_t* opt)
} else {
#if defined(PLATFORM_IS_MACOSX) && defined(PLATFORM_IS_ARM)
triple = LLVMCreateMessage("arm64-apple-macosx"
STRINGIFY(PONY_OSX_PLATFORM));
STR(PONY_OSX_PLATFORM));
#elif defined(PLATFORM_IS_MACOSX) && !defined(PLATFORM_IS_ARM)
triple = LLVMCreateMessage("x86_64-apple-macosx"
STRINGIFY(PONY_OSX_PLATFORM));
STR(PONY_OSX_PLATFORM));
#else
triple = LLVMGetDefaultTargetTriple();
#endif
Expand Down
5 changes: 3 additions & 2 deletions src/libponyc/codegen/genexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
# include <unistd.h>
#endif

#define STRINGIFY(x) #x
#define STR(x) STR2(x)
#define STR2(x) #x

static LLVMValueRef create_main(compile_t* c, reach_type_t* t,
LLVMValueRef ctx)
Expand Down Expand Up @@ -297,7 +298,7 @@ static bool link_exe(compile_t* c, ast_t* program,
snprintf(ld_cmd, ld_len,
"%s -execute -arch %.*s "
"-o %s %s %s %s "
"-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem %s -platform_version macos '" STRINGIFY(PONY_OSX_PLATFORM) "' '0.0.0'",
"-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem %s -platform_version macos '" STR(PONY_OSX_PLATFORM) "' '0.0.0'",
linker, (int)arch_len, c->opt->triple, file_exe, file_o,
lib_args, ponyrt, sanitizer_arg
);
Expand Down

0 comments on commit 44e02d3

Please sign in to comment.