diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5abb327d93..44e1f10073 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,7 @@ option(JEMALLOC "JEMALLOC" OFF) option(JSON "JSON" ON) # When OFF we disable LLVM support option(LLVM "LLVM" OFF) +option(COMPRESSED_OBJECT_HEADER "COMPRESSED_OBJECT_HEARDER" ON) # When cross-compiling, we do not compile the standard library since # the executable will not work on the host machine @@ -129,6 +130,25 @@ if ("${SMALL_ALLOCATOR}" MATCHES "ON") set(LEAN_SMALL_ALLOCATOR "#define LEAN_SMALL_ALLOCATOR") endif() +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + message(STATUS "64-bit machine detected") + set(NumBits 64) +else() + message(STATUS "32-bit machine detected") + set(NumBits 32) +endif() + +if ("${COMPRESSED_OBJECT_HEADER}" MATCHES "ON") + if (NumBits EQUAL "64") + set(LEAN_COMPRESSED_OBJECT_HEADER "#define LEAN_COMPRESSED_OBJECT_HEADER") + message(STATUS "Using compressed object headers, this feature assume the OS only uses memory addresses < 2^48") + else() + message(STATUS "Compressed object headers cannot be used in 32-bit machines") + endif() +else() + message(STATUS "Using big object headers") +endif() + if ("${RUNTIME_STATS}" MATCHES "ON") set(LEAN_EXTRA_CXX_FLAGS "${LEAN_EXTRA_CXX_FLAGS} -D LEAN_RUNTIME_STATS") endif() diff --git a/src/config.h.in b/src/config.h.in index e5c4b871bd..7c2f3d8725 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -7,3 +7,4 @@ Author: Leonardo de Moura #pragma once @LEAN_SMALL_ALLOCATOR@ @LEAN_LAZY_RC@ +@LEAN_COMPRESSED_OBJECT_HEADER@ diff --git a/src/runtime/lean.h b/src/runtime/lean.h index b16f4a33de..7848975a67 100644 --- a/src/runtime/lean.h +++ b/src/runtime/lean.h @@ -15,9 +15,6 @@ Author: Leonardo de Moura #include #endif -#define LEAN_SMALL_ALLOCATOR -// #define LEAN_COMPRESSED_OBJECT_HEADER - #ifdef __cplusplus #include #define _Atomic(t) std::atomic @@ -27,6 +24,7 @@ extern "C" { #include #define LEAN_USING_STD #endif +#include "config.h" #define LEAN_CLOSURE_MAX_ARGS 16 #define LEAN_OBJECT_SIZE_DELTA 8