Skip to content
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
4 changes: 4 additions & 0 deletions compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ option(COMPILER_RT_USE_BUILTINS_LIBRARY

include(config-ix)

configure_file(
${COMPILER_RT_SOURCE_DIR}/include/config/config.h.cmake
${COMPILER_RT_BINARY_DIR}/include/config/config.h)

#================================
# Setup Compiler Flags
#================================
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ check_cxx_compiler_flag(-Werror -Wsizeof-pointer-div COMPILER_RT_HAS_SIZEOF_POIN

# Symbols.
check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL)
check_symbol_exists(sysconf unistd.h COMPILER_RT_HAS_SYSCONF)

# Includes.
check_cxx_compiler_flag(-nostdinc++ COMPILER_RT_HAS_NOSTDINCXX_FLAG)
Expand Down
6 changes: 6 additions & 0 deletions compiler-rt/include/config/config.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef CONFIG_H
#define CONFIG_H

#cmakedefine COMPILER_RT_HAS_SYSCONF

#endif
2 changes: 2 additions & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ include(CMakePushCheckState)
option(COMPILER_RT_BUILTINS_HIDE_SYMBOLS
"Do not export any symbols from the static library." ON)

include_directories(${COMPILER_RT_BINARY_DIR}/include/config)

# TODO: Need to add a mechanism for logging errors when builtin source files are
# added to a sub-directory and not this CMakeLists file.
set(GENERIC_SOURCES
Expand Down
11 changes: 4 additions & 7 deletions compiler-rt/lib/builtins/enable_execute_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
#include <sys/mman.h>
#endif

// #include "config.h"
// FIXME: CMake - include when cmake system is ready.
// Remove #define HAVE_SYSCONF 1 line.
#define HAVE_SYSCONF 1
#include "config.h"

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -50,11 +47,11 @@ COMPILER_RT_ABI void __enable_execute_stack(void *addr) {
#if __APPLE__
// On Darwin, pagesize is always 4096 bytes
const uintptr_t pageSize = 4096;
#elif !defined(HAVE_SYSCONF)
#error "HAVE_SYSCONF not defined! See enable_execute_stack.c"
#elif !defined(COMPILER_RT_HAS_SYSCONF)
#error "COMPILER_RT_HAS_SYSCONF not defined! See enable_execute_stack.c"
#else
const uintptr_t pageSize = sysconf(_SC_PAGESIZE);
#endif // __APPLE__
#endif

const uintptr_t pageAlignMask = ~(pageSize - 1);
uintptr_t p = (uintptr_t)addr;
Expand Down