<commit_before>cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

project(libponyrt VERSION ${PONYC_PROJECT_VERSION} LANGUAGES C CXX)

set(_c_src
    actor/actor.c
    actor/messageq.c
    asio/asio.c
    asio/epoll.c
    asio/event.c
    asio/iocp.c
    asio/kqueue.c
    ds/fun.c
    ds/hash.c
    ds/list.c
    ds/stack.c
    gc/actormap.c
    gc/cycle.c
    gc/delta.c
    gc/gc.c
    gc/objectmap.c
    gc/serialise.c
    gc/trace.c
    lang/directory.c
    lang/io.c
    lang/lsda.c
    lang/paths.c
    lang/posix_except.c
    lang/process.c
    lang/socket.c
    lang/ssl.c
    lang/stat.c
    lang/stdfd.c
    lang/time.c
    lang/win_except.c
    mem/alloc.c
    mem/heap.c
    mem/pagemap.c
    mem/pool.c
    options/options.c
    platform/ponyassert.c
    platform/threads.c
    sched/cpu.c
    sched/mpmcq.c
    sched/mutemap.c
    sched/scheduler.c
    sched/start.c
)

set(_ll_except_src "${CMAKE_SOURCE_DIR}/src/libponyrt/lang/except_try_catch.ll")
set(_ll_except_obj "${CMAKE_BINARY_DIR}/except_try_catch.o")

find_file(_llc_command
    NAMES llc.exe llc
    PATHS "${CMAKE_BINARY_DIR}/../../libs/bin" "${CMAKE_BINARY_DIR}/../libs/bin"
)

add_library(libponyrt STATIC
    ${_c_src}
    ${_ll_except_obj}
)
set_source_files_properties(${ll_obj} PROPERTIES EXTERNAL_OBJECT True)

add_custom_command(
    COMMAND "${_llc_command}" ${LL_FLAGS} ${_ll_obj_flags} -relocation-model=pic -filetype=obj -o ${_ll_except_obj} ${_ll_except_src}
    WORKING_DIRECTORY ${libponyrt_BINARY_DIR}
    DEPENDS ${_ll_except_src}
    OUTPUT ${_ll_except_obj}
)

target_include_directories(libponyrt
    PRIVATE .
    PRIVATE ../common
)

if (MSVC)
    file(GLOB_RECURSE CFILES "${PROJECT_SOURCE_DIR}/*.c")
    set_source_files_properties(${CFILES} PROPERTIES LANGUAGE CXX)

    # copy libponyrt to the ponyc directory for use when linking pony programs
    add_custom_command(TARGET libponyrt POST_BUILD
        COMMAND $<$<CONFIG:Debug>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/debug/libponyrt.lib ${CMAKE_BINARY_DIR}/../debug/libponyrt.lib
        COMMAND $<$<CONFIG:Release>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/release/libponyrt.lib ${CMAKE_BINARY_DIR}/../release/libponyrt.lib
        COMMAND $<$<CONFIG:RelWithDebInfo>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/relwithdebinfo/libponyrt.lib ${CMAKE_BINARY_DIR}/../relwithdebinfo/libponyrt.lib
        COMMAND $<$<CONFIG:MinSizeRel>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/minsizerel/libponyrt.lib ${CMAKE_BINARY_DIR}/../minsizerel/libponyrt.lib
    )<commit_msg>Require mcx16 on generic x86-64<commit_after>cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

project(libponyrt VERSION ${PONYC_PROJECT_VERSION} LANGUAGES C CXX)

set(_c_src
    actor/actor.c
    actor/messageq.c
    asio/asio.c
    asio/epoll.c
    asio/event.c
    asio/iocp.c
    asio/kqueue.c
    ds/fun.c
    ds/hash.c
    ds/list.c
    ds/stack.c
    gc/actormap.c
    gc/cycle.c
    gc/delta.c
    gc/gc.c
    gc/objectmap.c
    gc/serialise.c
    gc/trace.c
    lang/directory.c
    lang/io.c
    lang/lsda.c
    lang/paths.c
    lang/posix_except.c
    lang/process.c
    lang/socket.c
    lang/ssl.c
    lang/stat.c
    lang/stdfd.c
    lang/time.c
    lang/win_except.c
    mem/alloc.c
    mem/heap.c
    mem/pagemap.c
    mem/pool.c
    options/options.c
    platform/ponyassert.c
    platform/threads.c
    sched/cpu.c
    sched/mpmcq.c
    sched/mutemap.c
    sched/scheduler.c
    sched/start.c
)

set(_ll_except_src "${CMAKE_SOURCE_DIR}/src/libponyrt/lang/except_try_catch.ll")
set(_ll_except_obj "${CMAKE_BINARY_DIR}/except_try_catch.o")

find_file(_llc_command
    NAMES llc.exe llc
    PATHS "${CMAKE_BINARY_DIR}/../../libs/bin" "${CMAKE_BINARY_DIR}/../libs/bin"
)

add_library(libponyrt STATIC
    ${_c_src}
    ${_ll_except_obj}
)

if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86-64")
    target_compile_options(libponyrt PUBLIC -mcx16)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
    target_compile_options(libponyrt PUBLIC -mcx16)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
   target_compile_options(libponyrt PUBLIC -mcx16)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
   target_compile_options(libponyrt PUBLIC -mcx16)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
   target_compile_options(libponyrt PUBLIC -mcx16)
endif()

set_source_files_properties(${ll_obj} PROPERTIES EXTERNAL_OBJECT True)

add_custom_command(
    COMMAND "${_llc_command}" ${LL_FLAGS} ${_ll_obj_flags} -relocation-model=pic -filetype=obj -o ${_ll_except_obj} ${_ll_except_src}
    WORKING_DIRECTORY ${libponyrt_BINARY_DIR}
    DEPENDS ${_ll_except_src}
    OUTPUT ${_ll_except_obj}
)

target_include_directories(libponyrt
    PRIVATE .
    PRIVATE ../common
)

if (MSVC)
    file(GLOB_RECURSE CFILES "${PROJECT_SOURCE_DIR}/*.c")
    set_source_files_properties(${CFILES} PROPERTIES LANGUAGE CXX)

    # copy libponyrt to the ponyc directory for use when linking pony programs
    add_custom_command(TARGET libponyrt POST_BUILD
        COMMAND $<$<CONFIG:Debug>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/debug/libponyrt.lib ${CMAKE_BINARY_DIR}/../debug/libponyrt.lib
        COMMAND $<$<CONFIG:Release>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/release/libponyrt.lib ${CMAKE_BINARY_DIR}/../release/libponyrt.lib
        COMMAND $<$<CONFIG:RelWithDebInfo>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/relwithdebinfo/libponyrt.lib ${CMAKE_BINARY_DIR}/../relwithdebinfo/libponyrt.lib
        COMMAND $<$<CONFIG:MinSizeRel>:${CMAKE_COMMAND}> ARGS -E copy ${libponyrt_BINARY_DIR}/minsizerel/libponyrt.lib ${CMAKE_BINARY_DIR}/../minsizerel/libponyrt.lib
    )
{'fraction_non_alphanumeric': 0.12394366197183099, 'fraction_numerical': 0.006338028169014085, 'mean_word_length': 3.687293729372937, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7561716', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2273, 'n_words': 321}