feat(CMakeLists.txt): add "COMPRESSED_OBJECT_HEADER" cmake option

This commit is contained in:
Leonardo de Moura 2019-08-23 13:04:53 -07:00
parent e7c8e66986
commit cee0264363
3 changed files with 22 additions and 3 deletions

View file

@ -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()

View file

@ -7,3 +7,4 @@ Author: Leonardo de Moura
#pragma once
@LEAN_SMALL_ALLOCATOR@
@LEAN_LAZY_RC@
@LEAN_COMPRESSED_OBJECT_HEADER@

View file

@ -15,9 +15,6 @@ Author: Leonardo de Moura
#include <malloc.h>
#endif
#define LEAN_SMALL_ALLOCATOR
// #define LEAN_COMPRESSED_OBJECT_HEADER
#ifdef __cplusplus
#include <atomic>
#define _Atomic(t) std::atomic<t>
@ -27,6 +24,7 @@ extern "C" {
#include <stdatomic.h>
#define LEAN_USING_STD
#endif
#include "config.h"
#define LEAN_CLOSURE_MAX_ARGS 16
#define LEAN_OBJECT_SIZE_DELTA 8