Skip to content

Add MingW support #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR APPLE)
# set fmtlib visibility to default
target_compile_definitions(ArkReactor PUBLIC FMT_SHARED)

# Enable FMT_LIB_EXPORT on MingW, otherwise it will fail to compile.
if (MINGW)
target_compile_definitions(ArkReactor PUBLIC FMT_LIB_EXPORT)
# Add -static to linking flags for MingW, otherwise it will
# dynamically link to libgcc_s_seh-1.dll, libwinpthread-1.dll
# and libstdc++-6.dll
target_link_options(ArkReactor PRIVATE -static)
endif ()

if (APPLE)
# The standard SSH libraries are depreciate on APPLE.
# Thus they currently generate a warning that we have to ignore for now.
Expand Down Expand Up @@ -198,6 +207,10 @@ if (ARK_TESTS)
add_executable(unittests ${SOURCES})
target_include_directories(unittests PUBLIC ${ark_SOURCE_DIR}/tests/unittests)

if (MINGW)
target_link_options(unittests PRIVATE -static)
endif ()

target_include_directories(unittests SYSTEM PUBLIC ${ark_SOURCE_DIR}/lib/dtl/dtl)

add_subdirectory(${ark_SOURCE_DIR}/lib/ut)
Expand Down Expand Up @@ -284,6 +297,11 @@ if (ARK_BUILD_EXE)
set_target_properties(arkscript PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE BATCH UNITY_BUILD_BATCH_SIZE 16)
endif ()

if (MINGW)
# Statically link the arkscript executable
target_link_options(arkscript PRIVATE -static)
endif ()

enable_lto(arkscript)

# Installs the arkscript executable.
Expand Down
2 changes: 1 addition & 1 deletion include/Ark/Compiler/AST/BaseParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace Ark::internal
*
* @return distance in characters from the beginning of the file to the cursor
*/
long getCount() { return std::distance(m_str.begin(), m_it); }
ssize_t getCount() { return std::distance(m_str.begin(), m_it); }

/**
*
Expand Down
5 changes: 4 additions & 1 deletion include/Ark/VM/Plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ namespace Ark::internal
T funcptr;

#if defined(ARK_OS_WINDOWS)
if (NULL == (funcptr = reinterpret_cast<T>(GetProcAddress(m_instance, procname.c_str()))))
// casting from FARPROC -> void* -> T is required on MingW
// target, immediate conversion from FARPROC -> T will fail.
void* pluginhandle = reinterpret_cast<void*>(GetProcAddress(m_instance, procname.c_str()));
if (NULL == (funcptr = reinterpret_cast<T>(pluginhandle)))
{
throw std::system_error(
std::error_code(::GetLastError(), std::system_category()), std::string("PluginError: Couldn't find ") + procname);
Expand Down
6 changes: 5 additions & 1 deletion include/Proxy/MiniWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
# define _ARM_
# endif

# define NOMINMAX
// Do not define NOMINMAX, if it's already defined (without, the
// #define causes issues on MingW)
# ifndef NOMINMAX
# define NOMINMAX
# endif

// https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
# include <errhandlingapi.h>
Expand Down
Loading