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
14 changes: 1 addition & 13 deletions CMake/HHVMExtensionConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,7 @@ function (HHVM_EXTENSION_INTERNAL_SORT_OUT_SOURCES rootDir)
elseif (${fileExtension} STREQUAL ".h" OR ${fileExtension} STREQUAL ".hpp")
list(APPEND HEADER_SOURCES "${rootDir}/${fileName}")
elseif (${fileExtension} STREQUAL ".s")
# AT&T syntax, MSVC doesn't like.
if (NOT MSVC)
list(APPEND ASM_SOURCES "${rootDir}/${fileName}")
endif()
elseif (${fileExtension} STREQUAL ".asm")
# MASM syntax. MSVC only.
if (MSVC)
list(APPEND ASM_SOURCES "${rootDir}/${fileName}")
endif()
list(APPEND ASM_SOURCES "${rootDir}/${fileName}")
elseif (${fileExtension} STREQUAL ".php")
list(APPEND PHP_SOURCES "${rootDir}/${fileName}")
elseif (${fileExtension} STREQUAL ".hack")
Expand Down Expand Up @@ -530,10 +522,6 @@ function(HHVM_EXTENSION_INTERNAL_RESOLVE_DEPENDENCIES_OF_EXTENSION resolvedDestV
if (${listIDX} EQUAL 0)
# OS Dependency
if (${currentDependency} STREQUAL "osPosix")
if (MSVC)
HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${currentDependency} ON)
break()
endif()
else()
message(FATAL_ERROR "The only OS restriction that is currently valid is 'osPosix', got '${currentDependency}'!")
endif()
Expand Down
17 changes: 1 addition & 16 deletions CMake/HHVMGenerateConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ function(HHVM_GENERATE_CONFIG_FUNCTIONS_FOUND_DEFINE_STRING destVarName)
"utimes"
)

# This is a list of functions that are known to be present under MSVC
# because they are implemented via Folly's portability headers. For an
# item in this list to have any effect, it must first fail to be found
# when checking the item in the main list.
set(HHVM_FUNCTIONS_KNOWN_TO_BE_PRESENT_MSVC)
list(APPEND HHVM_FUNCTIONS_KNOWN_TO_BE_PRESENT_MSVC
"mkstemp"
"mmap"
)

set(builtString "")
list(LENGTH HHVM_FUNCTIONS_TO_CHECK functionCount)
set(i 0)
Expand All @@ -86,12 +76,7 @@ function(HHVM_GENERATE_CONFIG_FUNCTIONS_FOUND_DEFINE_STRING destVarName)
if (${HAVE_${curFuncUpper}})
set(builtString "${builtString}\n#define HAVE_${curFuncUpper} 1")
else()
list(FIND HHVM_FUNCTIONS_KNOWN_TO_BE_PRESENT_MSVC "${curFunc}" curFuncIdx)
if (curFuncIdx EQUAL -1 OR NOT MSVC)
set(builtString "${builtString}\n/* #undef HAVE_${curFuncUpper} */")
else()
set(builtString "${builtString}\n#define HAVE_${curFuncUpper} 1 /* Implemented via Folly Portability header */")
endif()
set(builtString "${builtString}\n/* #undef HAVE_${curFuncUpper} */")
endif()
math(EXPR i "${i} + 1")
endwhile()
Expand Down
422 changes: 13 additions & 409 deletions CMake/HPHPCompiler.cmake

Large diffs are not rendered by default.

47 changes: 8 additions & 39 deletions CMake/HPHPFindLibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,7 @@ macro(hphp_link target)

target_link_libraries(${target} ${VISIBILITY} tbb)

if (NOT MSVC)
target_link_libraries(${target} ${VISIBILITY} afdt)
endif()
target_link_libraries(${target} ${VISIBILITY} afdt)
target_link_libraries(${target} ${VISIBILITY} mbfl)

if (EDITLINE_LIBRARIES)
Expand All @@ -427,44 +425,15 @@ macro(hphp_link target)
target_link_libraries(${target} ${VISIBILITY} ${READLINE_LIBRARY})
endif()

if (MSVC)
target_link_libraries(${target} ${VISIBILITY} dbghelp.lib dnsapi.lib)
find_library(ATOMIC_LIBRARY NAMES atomic libatomic.so.1)
if (ATOMIC_LIBRARY STREQUAL "ATOMIC_LIBRARY-NOTFOUND")
# -latomic should be available for gcc even when libatomic.so.1 is not
# in the library search path
target_link_libraries(${target} ${VISIBILITY} atomic)
else()
target_link_libraries(${target} ${VISIBILITY} ${ATOMIC_LIBRARY})
endif()

# Check whether atomic operations require -latomic or not
# See https://github.com/facebook/hhvm/issues/5217
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-std=c++1y")
CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
#include <iostream>
#include <stdint.h>
int main() {
struct Test { int64_t val1; int64_t val2; };
std::atomic<Test> s;
// Do this to stop modern compilers from optimizing away the libatomic
// calls in release builds, making this test always pass in release builds,
// and incorrectly think that HHVM doesn't need linking against libatomic.
bool (std::atomic<Test>::* volatile x)(void) const =
&std::atomic<Test>::is_lock_free;
std::cout << (s.*x)() << std::endl;
}
" NOT_REQUIRE_ATOMIC_LINKER_FLAG)

if(NOT "${NOT_REQUIRE_ATOMIC_LINKER_FLAG}")
message(STATUS "-latomic is required to link hhvm")
find_library(ATOMIC_LIBRARY NAMES atomic libatomic.so.1)
if (ATOMIC_LIBRARY STREQUAL "ATOMIC_LIBRARY-NOTFOUND")
# -latomic should be available for gcc even when libatomic.so.1 is not
# in the library search path
target_link_libraries(${target} ${VISIBILITY} atomic)
else()
target_link_libraries(${target} ${VISIBILITY} ${ATOMIC_LIBRARY})
endif()
endif()
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})

if (ENABLE_XED)
if (LibXed_FOUND)
target_link_libraries(${target} ${VISIBILITY} ${LibXed_LIBRARY})
Expand Down
97 changes: 17 additions & 80 deletions CMake/HPHPFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,12 @@ macro(HHVM_SELECT_SOURCES DIR)
list(APPEND C_SOURCES ${f})
endif()
endforeach()
if (MSVC)
auto_sources(files "*.asm" "RECURSE" "${DIR}")
foreach(f ${files})
if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)"))
list(APPEND ASM_SOURCES ${f})
endif()
endforeach()
else()
auto_sources(files "*.S" "RECURSE" "${DIR}")
foreach(f ${files})
if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)"))
list(APPEND ASM_SOURCES ${f})
endif()
endforeach()
endif()
auto_sources(files "*.S" "RECURSE" "${DIR}")
foreach(f ${files})
if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)"))
list(APPEND ASM_SOURCES ${f})
endif()
endforeach()
auto_sources(files "*.h" "RECURSE" "${DIR}")
foreach(f ${files})
if (NOT (${f} MATCHES "(/(old-)?tests?/)"))
Expand Down Expand Up @@ -113,21 +104,14 @@ macro(MYSQL_SOCKET_SEARCH)
endmacro()

function(append_systemlib TARGET SOURCE SECTNAME)
if(MSVC)
list(APPEND ${TARGET}_SLIBS_NAMES "${SECTNAME}")
set(${TARGET}_SLIBS_NAMES ${${TARGET}_SLIBS_NAMES} PARENT_SCOPE)
list(APPEND ${TARGET}_SLIBS_SOURCES "${SOURCE}")
set(${TARGET}_SLIBS_SOURCES ${${TARGET}_SLIBS_SOURCES} PARENT_SCOPE)
if (APPLE)
set(${TARGET}_SLIBS ${${TARGET}_SLIBS} -Wl,-sectcreate,__text,${SECTNAME},${SOURCE} PARENT_SCOPE)
else()
if (APPLE)
set(${TARGET}_SLIBS ${${TARGET}_SLIBS} -Wl,-sectcreate,__text,${SECTNAME},${SOURCE} PARENT_SCOPE)
else()
set(${TARGET}_SLIBS ${${TARGET}_SLIBS} "--add-section" "${SECTNAME}=${SOURCE}" PARENT_SCOPE)
endif()
# Add the systemlib file to the "LINK_DEPENDS" for the systemlib, this will cause it
# to be relinked and the systemlib re-embedded
set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS ${SOURCE})
set(${TARGET}_SLIBS ${${TARGET}_SLIBS} "--add-section" "${SECTNAME}=${SOURCE}" PARENT_SCOPE)
endif()
# Add the systemlib file to the "LINK_DEPENDS" for the systemlib, this will cause it
# to be relinked and the systemlib re-embedded
set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS ${SOURCE})
endfunction(append_systemlib)

function(embed_sections TARGET DEST)
Expand All @@ -150,24 +134,6 @@ function(embed_sections TARGET DEST)
set(REPO_SCHEMA -Wl,-sectcreate,__text,"repo_schema_id","${CMAKE_BINARY_DIR}/hphp/util/generated-repo-schema-id.txt")
set(BUILD_ID -Wl,-sectcreate,__text,"build_id","${CMAKE_BINARY_DIR}/hphp/util/generated-build-id.txt")
target_link_libraries(${TARGET} ${${TARGET}_SLIBS} ${COMPILER_ID} ${COMPILER_TIMESTAMP} ${REPO_SCHEMA} ${BUILD_ID})
elseif(MSVC)
set(RESOURCE_FILE "#pragma code_page(1252)\n")
set(RESOURCE_FILE "${RESOURCE_FILE}LANGUAGE 0, 0\n")
set(RESOURCE_FILE "${RESOURCE_FILE}\n")
set(RESOURCE_FILE "${RESOURCE_FILE}#include \"${CMAKE_BINARY_DIR}/hphp/runtime/version.h\"\n")
file(READ "${CMAKE_BINARY_DIR}/hphp/hhvm/hhvm.rc" VERSION_INFO)
set(RESOURCE_FILE "${RESOURCE_FILE}compiler_id RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-id.txt\"\n")
set(RESOURCE_FILE "${RESOURCE_FILE}compiler_ts RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-timestamp.txt\"\n")
set(RESOURCE_FILE "${RESOURCE_FILE}repo_schema_id RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-repo-schema-id.txt\"\n")
set(RESOURCE_FILE "${RESOURCE_FILE}build_id RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-build-id.txt\"\n")
set(RESOURCE_FILE "${RESOURCE_FILE}${VERSION_INFO}\n")
set(i 0)
foreach (nm ${${TARGET}_SLIBS_NAMES})
list(GET ${TARGET}_SLIBS_SOURCES ${i} source)
set(RESOURCE_FILE "${RESOURCE_FILE}${nm} RCDATA \"${source}\"\n")
math(EXPR i "${i} + 1")
endforeach()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/embed.rc "${RESOURCE_FILE}")
else()
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND "objcopy"
Expand All @@ -193,13 +159,8 @@ macro(embed_systemlib_byname TARGET SLIB)
string(MD5 SLIB_HASH_NAME ${SLIB_EXTNAME})
# Some platforms limit section names to 16 characters :(
string(SUBSTRING ${SLIB_HASH_NAME} 0 12 SLIB_HASH_NAME_SHORT)
if (MSVC)
# The dot would be causing the RC lexer to begin a number in the
# middle of our resource name, so use an underscore instead.
append_systemlib(${TARGET} ${SLIB} "ext_${SLIB_HASH_NAME_SHORT}")
else()
append_systemlib(${TARGET} ${SLIB} "ext.${SLIB_HASH_NAME_SHORT}")
endif()

append_systemlib(${TARGET} ${SLIB} "ext.${SLIB_HASH_NAME_SHORT}")
endmacro()

function(embed_all_systemlibs TARGET ROOT DEST)
Expand Down Expand Up @@ -395,37 +356,20 @@ function(parse_version PREFIX VERSION)
set(${PREFIX}SUFFIX ${SUFFIX} PARENT_SCOPE)
endfunction()

# MSVC doesn't support a --whole-archive flag, but newer versions
# of CMake do support object libraries, which give the same result.
# As we can't easily upgrade the normal builds to CMake 3.0, we
# will just require CMake 3.0+ for MSVC builds only.
function(add_object_library libraryName)
if (MSVC)
add_library(${libraryName} OBJECT ${ARGN})
else()
add_library(${libraryName} STATIC ${ARGN})
endif()
add_library(${libraryName} STATIC ${ARGN})
endfunction()

# Get what might be the objects of the object libraries, if needed.
function(get_object_libraries_objects targetVariable)
set(OBJECTS)
if (MSVC)
foreach (fil ${ARGN})
list(APPEND OBJECTS $<TARGET_OBJECTS:${fil}>)
endforeach()
endif()

set(${targetVariable} ${OBJECTS} PARENT_SCOPE)
endfunction()

# Add the additional link targets for a set of object libraries,
# if needed.
function(link_object_libraries target)
if (MSVC)
return()
endif()

set(WHOLE_ARCHIVE_LIBS)
foreach (fil ${ARGN})
list(APPEND WHOLE_ARCHIVE_LIBS ${fil})
Expand Down Expand Up @@ -453,21 +397,14 @@ endfunction()
# This should be called for object libraries, rather than calling
# hphp_link directly.
function(object_library_hphp_link target)
# MSVC can't have it. (see below)
if (NOT MSVC)
hphp_link(${target})
endif()
hphp_link(${target})
endfunction()

# If a library needs to be linked in to make GNU ld happy,
# it should be done by calling this.
function(object_library_ld_link_libraries target)
if (${ARGC})
# CMake doesn't allow calls to target_link_libraries if the target
# is an OBJECT library, so MSVC can't have this.
if (NOT MSVC)
target_link_libraries(${target} ${ARGN})
endif()
target_link_libraries(${target} ${ARGN})
endif()
endfunction()

Expand Down
2 changes: 0 additions & 2 deletions CMake/HPHPIZEFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ endfunction()
function(embed_systemlibs TARGET DEST)
if (APPLE)
target_link_libraries(${TARGET} ${${TARGET}_SLIBS})
elseif (MSVC)
message(FATAL_ERROR "Shared extensions are not supported on Windows")
else()
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND "objcopy"
Expand Down
16 changes: 2 additions & 14 deletions CMake/HPHPSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,8 @@ if (LINUX)
add_definitions(-D_GNU_SOURCE)
endif()

if(MSVC)
add_definitions(-DGLOG_NO_ABBREVIATED_SEVERITIES)
add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()

if(CMAKE_CONFIGURATION_TYPES)
if(NOT MSVC)
message(FATAL_ERROR "Adding the appropriate defines for multi-config targets using anything other than MSVC is not yet supported!")
endif()
foreach(flag_var
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
set(${flag_var} "${${flag_var}} /D NDEBUG")
endforeach()
message(FATAL_ERROR "Adding the appropriate defines for multi-config targets is not yet supported!")
elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug" OR
${CMAKE_BUILD_TYPE} MATCHES "DebugOpt")
message("Generating DEBUG build")
Expand All @@ -127,7 +115,7 @@ if(ALWAYS_ASSERT)
add_definitions(-DALWAYS_ASSERT=1)
endif()

if(APPLE OR FREEBSD OR MSVC)
if(APPLE OR FREEBSD)
add_definitions(-DSKIP_USER_CHANGE=1)
endif()

Expand Down
Loading