Skip to content

Commit

Permalink
Attempt to fix Ubuntu build
Browse files Browse the repository at this point in the history
  • Loading branch information
saharNooby committed Sep 19, 2023
1 parent 30edc62 commit fd163b6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
50 changes: 50 additions & 0 deletions CMakeLists.txt
Expand Up @@ -298,6 +298,56 @@ else()
message(STATUS "Unknown architecture")
endif()

#
# POSIX conformance
# Section copy-pasted from https://github.com/ggerganov/llama.cpp/blob/8781013ef654270cbead3e0011e33a6d690fb168/CMakeLists.txt#L580C20-L580C20
#

# clock_gettime came in POSIX.1b (1993)
# CLOCK_MONOTONIC came in POSIX.1-2001 / SUSv3 as optional
# posix_memalign came in POSIX.1-2001 / SUSv3
# M_PI is an XSI extension since POSIX.1-2001 / SUSv3, came in XPG1 (1985)
add_compile_definitions(_XOPEN_SOURCE=600)

# Somehow in OpenBSD whenever POSIX conformance is specified
# some string functions rely on locale_t availability,
# which was introduced in POSIX.1-2008, forcing us to go higher.
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
remove_definitions(-D_XOPEN_SOURCE=600)
add_compile_definitions(_XOPEN_SOURCE=700)
endif()

# Data types, macros and functions related to controlling CPU affinity and
# some memory allocation are available on Linux through GNU extensions in libc.
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_compile_definitions(_GNU_SOURCE)
endif()

# RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1,
# and on macOS its availability depends on enabling Darwin extensions.
# Similarly on DragonFly, enabling BSD extensions is necessary.
if (
CMAKE_SYSTEM_NAME MATCHES "Darwin" OR
CMAKE_SYSTEM_NAME MATCHES "iOS" OR
CMAKE_SYSTEM_NAME MATCHES "tvOS" OR
CMAKE_SYSTEM_NAME MATCHES "DragonFly"
)
add_compile_definitions(_DARWIN_C_SOURCE)
endif()

# alloca is a non-standard interface that is not visible on BSDs when
# POSIX conformance is specified, but not all of them provide a clean way
# to enable it in such cases.
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_compile_definitions(__BSD_VISIBLE)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_compile_definitions(_NETBSD_SOURCE)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_compile_definitions(_BSD_SOURCE)
endif()

#
# Build libraries
#
Expand Down
3 changes: 1 addition & 2 deletions tests/CMakeLists.txt
Expand Up @@ -19,8 +19,7 @@ file(COPY tiny-rwkv-660K-Q5_0.bin DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY tiny-rwkv-660K-Q5_1.bin DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY expected_logits.bin DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

# TODO Restore
#rwkv_add_test(test_ggml_basics.c)
rwkv_add_test(test_ggml_basics.c)
rwkv_add_test(test_quantized_matmul_on_gpu.c)
rwkv_add_test(test_tiny_rwkv.c)
rwkv_add_test(test_quantization_format_compatibility.c)
Expand Down

0 comments on commit fd163b6

Please sign in to comment.