Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tools/objc/*.mobileprovision


*.txt.user*
.idea
.idea/

# jrk editor settings
.tm_properties
Expand Down Expand Up @@ -88,6 +88,7 @@ src/.tags
src/.tags_sorted_by_file

/.vs
/out
/CMakeSettings.json
/venv/
/cmake-build-*/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(Halide VERSION 1.0.0)
project(Halide VERSION 10.0.0)

enable_testing()

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ RISCV_CXX_FLAGS=$(if $(WITH_RISCV), -DWITH_RISCV, )
RISCV_LLVM_CONFIG_LIB=$(if $(WITH_RISCV), riscv, )

INTROSPECTION_CXX_FLAGS=$(if $(WITH_INTROSPECTION), -DWITH_INTROSPECTION, )
EXCEPTIONS_CXX_FLAGS=$(if $(WITH_EXCEPTIONS), -DWITH_EXCEPTIONS -fexceptions, )
EXCEPTIONS_CXX_FLAGS=$(if $(WITH_EXCEPTIONS), -DHALIDE_WITH_EXCEPTIONS -fexceptions, )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this renaming necessary?

@alexreinking alexreinking Jul 23, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the behavior of Error.cpp changes depending on whether or not Halide was built with exceptions, so our users might need to know whether it was enabled. The old name, WITH_EXCEPTIONS, is almost guaranteed to conflict with another project so I prefixed it. It also now matches HALIDE_ENABLE_RTTI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this macro is ever exported though. It's only used in Error.cpp, and no headers. This is now inconsistent with all the other WITH flags in the makefile.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we think clients might need to check it dynamically should we add an api like we did for llvm_version?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use cases for checking it would seem to need to be compile-time mostly, I would think (e.g. so that you can wrap try/catch or not).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So perhaps it should be something exported by the Halide package in cmake (not sure of correct terminology here) as the variable HALIDE_WITH_EXCEPTIONS? But this is independent of what the #define is called.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linking with varying exception-handling capabilities is generally risky, as is linking with varying RTTI info, which is why packages that allow users to disable them have to propagate that information at build time.


HEXAGON_CXX_FLAGS=$(if $(WITH_HEXAGON), -DWITH_HEXAGON, )
HEXAGON_LLVM_CONFIG_LIB=$(if $(WITH_HEXAGON), hexagon, )
Expand Down
4 changes: 2 additions & 2 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function(add_app_test NAME)
# Don't attempt to build these for wasm yet.
return()
endif ()

unset(cmakeToolchainOpts)
if (NOT "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
list(APPEND cmakeToolchainOpts "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
Expand Down Expand Up @@ -55,7 +55,7 @@ function(add_app_test NAME)
add_test(NAME ${NAME}
COMMAND ${CMAKE_CTEST_COMMAND}
--output-on-failure
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}" "${CMAKE_CURRENT_BINARY_DIR}/app_test_${NAME}"
--build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}"
--build-generator "${CMAKE_GENERATOR}"
${cmakeGenOpts}
--build-config "$<CONFIG>"
Expand Down
3 changes: 2 additions & 1 deletion apps/autoscheduler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

if (NOT BUILD_SHARED_LIBS)
if (MSVC)
message(FATAL_ERROR "Autoscheduler plugins cannot be built against static Halide on Windows")
message(WARNING "Autoscheduler plugins cannot be built against static Halide on Windows")
return()
endif ()

# Need to enable exports for the plugins to find Halide's symbols.
Expand Down
5 changes: 3 additions & 2 deletions apps/gradient_autoscheduler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

if (NOT BUILD_SHARED_LIBS)
if (MSVC)
message(FATAL_ERROR "Autoscheduler plugins cannot be built against static Halide on Windows")
endif()
message(WARNING "Autoscheduler plugins cannot be built against static Halide on Windows")
return()
endif ()

# Need to enable exports for the plugins to find Halide's symbols.
set(CMAKE_ENABLE_EXPORTS ON)
Expand Down
8 changes: 4 additions & 4 deletions apps/support/cmdline.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// GitHub source: from https://github.com/tanakh/cmdline
// Modifications made in-place to remove the use of exceptions,
// flagged with WITH_EXCEPTIONS
// flagged with HALIDE_WITH_EXCEPTIONS

/*
Copyright (c) 2009, Hideyuki Tanaka
Expand Down Expand Up @@ -59,7 +59,7 @@ namespace cmdline {

namespace detail {

#ifdef WITH_EXCEPTIONS
#ifdef HALIDE_WITH_EXCEPTIONS
inline void throw_bad_cast() {
throw std::bad_cast();
}
Expand Down Expand Up @@ -184,7 +184,7 @@ inline std::string readable_typename<int>() {

//-----

#ifdef WITH_EXCEPTIONS
#ifdef HALIDE_WITH_EXCEPTIONS
class cmdline_error : public std::exception {
public:
cmdline_error(const std::string &msg)
Expand Down Expand Up @@ -783,7 +783,7 @@ class parser {
}

bool set(const std::string &value) override {
#ifdef WITH_EXCEPTIONS
#ifdef HALIDE_WITH_EXCEPTIONS
try {
actual = read(value);
has = true;
Expand Down
200 changes: 200 additions & 0 deletions cmake/BundleStatic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
cmake_minimum_required(VERSION 3.16)

##
# This module provides a utility for bundling a set of IMPORTED
# STATIC libraries together as a merged INTERFACE library that,
# due to CMake Issue #15415, requires manual propagation to its
# linkees, unfortunately.
#
# This is useful when a STATIC library produced by your project
# depends privately on some 3rd-party STATIC libraries that are
# tricky to distribute or for end-users to build. CMake handles
# this by assuming that imported libraries will be easy to find
# in an end-user's environment so a simple find_dependency call
# in the package config will suffice. Unfortunately, things are
# not so simple. Some libraries (eg. LLVM) can be built in many
# different configurations, and dependents can be built against
# one fixed configuration. If we have LLVM -> X -> Y where X is
# my library and Y is some other user's library, then Y must be
# very careful to build LLVM in _exactly_ the same way as X was
# configured to use. While this might be acceptable in a super-
# build, it fails when we want to release binary packages of X.
##

# All of the IMPORTED_ and INTERFACE_ properties should be accounted for below.
# https://cmake.org/cmake/help/v3.16/manual/cmake-properties.7.html#properties-on-targets

# Irrelevant properties:
# IMPORTED_IMPLIB(_<CONFIG>) # shared-only
# IMPORTED_LIBNAME(_<CONFIG>) # interface-only
# IMPORTED_LINK_DEPENDENT_LIBRARIES(_<CONFIG>) # shared-only
# IMPORTED_LINK_INTERFACE_LIBRARIES(_<CONFIG>) # deprecated
# IMPORTED_LINK_INTERFACE_MULTIPLICITY(_<CONFIG>) # static-only. irrelevant when all objects listed.
# IMPORTED_NO_SONAME(_<CONFIG>) # shared-only
# IMPORTED_SONAME(_<CONFIG>) # shared-only

function(bundle_static)
set(options)
set(oneValueArgs TARGET)
set(multiValueArgs LIBRARIES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(interfaceLib ${ARG_TARGET})
set(objectLib ${ARG_TARGET}.obj)

add_library(${interfaceLib} INTERFACE)
add_library(${objectLib} OBJECT IMPORTED)
set_target_properties(${objectLib} PROPERTIES IMPORTED_GLOBAL TRUE)

target_sources(${interfaceLib} INTERFACE $<BUILD_INTERFACE:$<TARGET_OBJECTS:${objectLib}>>)

set(queue ${ARG_LIBRARIES})
while (queue)
list(POP_FRONT queue lib)
if (VISITED_${lib})
continue()
endif ()
set(VISITED_${lib} TRUE)

if (NOT TARGET ${lib})
target_link_libraries(${interfaceLib} INTERFACE ${lib})
continue()
endif ()

get_property(isImported TARGET ${lib} PROPERTY IMPORTED)
get_property(type TARGET ${lib} PROPERTY TYPE)

if (NOT isImported OR NOT "${type}" STREQUAL "STATIC_LIBRARY")
target_link_libraries(${interfaceLib} INTERFACE ${lib})
continue()
endif ()

transfer_same(PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE
FROM ${lib} TO ${interfaceLib})

transfer_append(PROPERTIES
INTERFACE_AUTOUIC_OPTIONS
INTERFACE_COMPILE_DEFINITIONS
INTERFACE_COMPILE_FEATURES
INTERFACE_COMPILE_OPTIONS
INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_LINK_DEPENDS
INTERFACE_LINK_DIRECTORIES
INTERFACE_LINK_OPTIONS
INTERFACE_PRECOMPILE_HEADERS
INTERFACE_SOURCES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
FROM ${lib} TO ${interfaceLib})

transfer_same(PROPERTIES IMPORTED_COMMON_LANGUAGE_RUNTIME
FROM ${lib} TO ${objectLib})

transfer_locations(FROM ${lib} TO ${objectLib})

get_property(deps TARGET ${lib} PROPERTY INTERFACE_LINK_LIBRARIES)
list(APPEND queue ${deps})
endwhile ()
endfunction()

function(transfer_same)
set(options)
set(oneValueArgs FROM TO PROPERTIES)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

foreach (p IN LISTS ARG_PROPERTIES)
get_property(fromSet TARGET ${ARG_FROM} PROPERTY ${p} SET)
if (NOT fromSet)
continue()
endif ()
get_property(fromVal TARGET ${ARG_FROM} PROPERTY ${p})

get_property(toSet TARGET ${ARG_TO} PROPERTY ${p} SET)
if (NOT toSet)
set_property(TARGET ${ARG_TO} PROPERTY ${p} ${fromVal})
endif ()

get_property(toVal TARGET ${ARG_TO} PROPERTY ${p})
if (NOT "${fromVal}" STREQUAL "${toVal}")
message(WARNING "Property ${p} does not agree between ${ARG_FROM} [${fromVal}] and ${ARG_TO} [${toVal}]")
endif ()
endforeach ()
endfunction()

function(transfer_append)
set(options)
set(oneValueArgs FROM TO PROPERTIES)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

foreach (p IN LISTS ARG_PROPERTIES)
get_property(fromSet TARGET ${ARG_FROM} PROPERTY ${p} SET)
if (fromSet)
get_property(fromVal TARGET ${ARG_FROM} PROPERTY ${p})
set_property(TARGET ${ARG_TO} APPEND PROPERTY ${p} ${fromVal})
endif ()
endforeach ()
endfunction()

function(transfer_locations)
set(options)
set(oneValueArgs FROM TO)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

get_property(configs TARGET ${ARG_FROM} PROPERTY IMPORTED_CONFIGURATIONS)
foreach (cfg IN LISTS configs ITEMS "")
if (cfg)
string(TOUPPER "_${cfg}" cfg)
endif ()

get_property(lib TARGET ${ARG_FROM} PROPERTY "IMPORTED_LOCATION${cfg}")
if (lib)
get_filename_component(stage "${lib}" NAME_WE)
set(stage "${CMAKE_CURRENT_BINARY_DIR}/${stage}.obj")

if (NOT EXISTS "${stage}")
file(MAKE_DIRECTORY "${stage}")
if (MSVC)
execute_process(COMMAND "${CMAKE_AR}" /NOLOGO /LIST "${lib}"
WORKING_DIRECTORY "${stage}"
OUTPUT_VARIABLE objsInLib)

# Process the output to a list of internal objects
string(STRIP "${objsInLib}" objsInLib)
string(REGEX REPLACE "(\r|\n)+" ";" objsInLib "${objsInLib}")
list(TRANSFORM objsInLib STRIP)

foreach (obj IN LISTS objsInLib)
execute_process(COMMAND "${CMAKE_AR}" /NOLOGO "/EXTRACT:${obj}" "${lib}"
WORKING_DIRECTORY "${stage}")
endforeach ()
else ()
execute_process(COMMAND "${CMAKE_AR}" -x "${lib}"
WORKING_DIRECTORY "${stage}"
RESULT_VARIABLE error)
endif ()
endif ()

get_property(languages TARGET ${ARG_FROM} PROPERTY "IMPORTED_LINK_INTERFACE_LANGUAGES${cfg}")
if (NOT languages)
get_property(languages TARGET ${ARG_FROM} PROPERTY "IMPORTED_LINK_INTERFACE_LANGUAGES")
endif ()

message(VERBOSE "Transferring ${languages}[${cfg}] objects from ${lib} to ${ARG_TO}")

unset(globs)
foreach (lang IN LISTS languages)
list(APPEND globs "${stage}/*${CMAKE_${lang}_OUTPUT_EXTENSION}")
endforeach ()

file(GLOB_RECURSE objects ${globs})

foreach (obj IN LISTS objects)
message(VERBOSE "... ${obj}")
endforeach ()

set_property(TARGET ${ARG_TO} APPEND PROPERTY "IMPORTED_OBJECTS${cfg}" ${objects})
endif ()
endforeach ()
endfunction()
1 change: 0 additions & 1 deletion dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ endif ()
# Third-party dependencies in their own subdirectories
##

add_subdirectory(clang)
add_subdirectory(llvm)

add_subdirectory(jpeg)
Expand Down
18 changes: 0 additions & 18 deletions dependencies/clang/CMakeLists.txt

This file was deleted.

Loading