Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for MinGW #4601

Merged
merged 4 commits into from
Feb 14, 2020
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
44 changes: 6 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ MAKEFLAGS += --no-builtin-rules
UNAME = $(shell uname)

ifeq ($(OS), Windows_NT)
# assume we are building for the MinGW environment
COMMON_LD_FLAGS=$(LDFLAGS) -luuid -lole32 -lpthread -lz -Wl,--stack,8388608
SHARED_EXT=dll
FPIC=
$(error Halide no longer supports the MinGW environment.)
else
# let's assume "normal" UNIX such as linux
COMMON_LD_FLAGS=$(LDFLAGS) -ldl -lpthread -lz
Expand Down Expand Up @@ -128,11 +125,7 @@ WITH_OPENCL ?= not-empty
WITH_METAL ?= not-empty
WITH_OPENGL ?= not-empty
WITH_D3D12 ?= not-empty
ifeq ($(OS), Windows_NT)
WITH_INTROSPECTION ?=
else
WITH_INTROSPECTION ?= not-empty
endif
WITH_INTROSPECTION ?= not-empty
WITH_EXCEPTIONS ?=
WITH_LLVM_INSIDE_SHARED_LIBHALIDE ?= not-empty

Expand Down Expand Up @@ -814,7 +807,6 @@ RUNTIME_CPP_COMPONENTS = \
metal \
metal_objc_arm \
metal_objc_x86 \
mingw_math \
mips_cpu_features \
module_aot_ref_count \
module_jit_ref_count \
Expand Down Expand Up @@ -954,21 +946,8 @@ all: distrib test_internal
# linker map file.
ifeq ($(UNAME), Darwin)
MAP_FLAGS= -Wl,-map -Wl,$(BUILD_DIR)/llvm_objects/list.all
LIST_OUTPUT = > /dev/null
else
ifeq ($(OS), Windows_NT)
# This is for MinGW: the map file gets written, but the
# compilation fails with a file truncation error. Instead,
# we use the old strategy.
# Note: we do in fact have to pass in this flag twice.
# Note: The grep in this line is necessary in order to avoid file truncation errors
# in MinGW.
MAP_FLAGS= -Wl,-t -Wl,-t
LIST_OUTPUT = 2>&1 | grep "libLLVM" | grep ")" > $(BUILD_DIR)/llvm_objects/list.all
else
MAP_FLAGS= -Wl,-Map=$(BUILD_DIR)/llvm_objects/list.all
LIST_OUTPUT = > /dev/null
endif
endif

$(BUILD_DIR)/llvm_objects/list: $(OBJECTS) $(INITIAL_MODULES)
Expand All @@ -977,7 +956,7 @@ $(BUILD_DIR)/llvm_objects/list: $(OBJECTS) $(INITIAL_MODULES)
# part of the linker map file, the object files in which archives it uses to
# resolve symbols. We only care about the libLLVM ones, which we will filter below.
@mkdir -p $(@D)
$(CXX) -o /dev/null -shared $(MAP_FLAGS) $(OBJECTS) $(INITIAL_MODULES) $(LLVM_STATIC_LIBS) $(LLVM_SYSTEM_LIBS) $(COMMON_LD_FLAGS) $(LIST_OUTPUT)
$(CXX) -o /dev/null -shared $(MAP_FLAGS) $(OBJECTS) $(INITIAL_MODULES) $(LLVM_STATIC_LIBS) $(LLVM_SYSTEM_LIBS) $(COMMON_LD_FLAGS) > /dev/null
# if the list has changed since the previous build, or there
# is no list from a previous build, then delete any old object
# files and re-extract the required object files
Expand All @@ -998,8 +977,7 @@ $(LIB_DIR)/libHalide.a: $(OBJECTS) $(INITIAL_MODULES) $(BUILD_DIR)/llvm_objects/
# Archive together all the halide and llvm object files
@mkdir -p $(@D)
@rm -f $(LIB_DIR)/libHalide.a
# ar breaks on MinGW with all objects at the same time.
echo $(OBJECTS) $(INITIAL_MODULES) $(BUILD_DIR)/llvm_objects/llvm_*.o* | xargs -n200 ar q $(LIB_DIR)/libHalide.a
ar q $(LIB_DIR)/libHalide.a $(OBJECTS) $(INITIAL_MODULES) $(BUILD_DIR)/llvm_objects/llvm_*.o*
ranlib $(LIB_DIR)/libHalide.a

$(BIN_DIR)/libHalide.$(SHARED_EXT): $(OBJECTS) $(INITIAL_MODULES) $(V8_DEPS)
Expand Down Expand Up @@ -1972,13 +1950,15 @@ time_compilation_generator_%: $(BIN_DIR)/%.generator

TEST_APPS=\
HelloMatlab \
autoscheduler \
bilateral_grid \
bgu \
blur \
c_backend \
camera_pipe \
conv_layer \
fft \
gradient_autoscheduler \
hist \
interpolate \
lens_blur \
Expand All @@ -1992,13 +1972,6 @@ TEST_APPS=\
stencil_chain \
wavelet

# TODO: apps/autoscheduler doesn't yet build properly for MinGW
# (see https://github.com/halide/Halide/issues/4069)
ifneq ($(OS), Windows_NT)
TEST_APPS += autoscheduler
TEST_APPS += gradient_autoscheduler
endif

TEST_APPS_DEPS=$(TEST_APPS:%=%_test_app)
BUILD_APPS_DEPS=$(TEST_APPS:%=%_build_app)

Expand Down Expand Up @@ -2063,18 +2036,13 @@ benchmark_apps: $(BENCHMARK_APPS)
# TODO(srj): the python bindings need to be put into the distrib folders;
# this is a hopefully-temporary workaround (https://github.com/halide/Halide/issues/4368)
.PHONY: build_python_bindings
ifneq ($(OS), Windows_NT)
build_python_bindings: distrib $(BIN_DIR)/host/runtime.a
$(MAKE) -C $(ROOT_DIR)/python_bindings \
-f $(ROOT_DIR)/python_bindings/Makefile \
build_python_bindings \
HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \
BIN=$(CURDIR)/$(BIN_DIR)/python3_bindings \
PYTHON=python3
else
# No Python support for MinGW yet
build_python_bindings: ;
endif

.PHONY: test_python
test_python: distrib $(BIN_DIR)/host/runtime.a build_python_bindings
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ To configure and build Halide:
% cmake -DLLVM_DIR=../llvm-install/lib/cmake/llvm -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 14 Win64" ../halide
% MSBuild.exe /m /t:Build /p:Configuration=Release .\ALL_BUILD.vcxproj

#### Building Halide and LLVM on Windows using mingw

The makefile method above should work from inside a "mingw64" shell
(not the default shell) in an msys2 installation.

#### If all else fails...

Do what the build-bots do: https://buildbot.halide-lang.org/master/#/builders
Expand Down
4 changes: 0 additions & 4 deletions apps/HelloAndroid/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ die ( ) {

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
Expand All @@ -37,9 +36,6 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac

# Attempt to set APP_HOME
Expand Down
4 changes: 0 additions & 4 deletions apps/HelloAndroidCamera2/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ die ( ) {

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
Expand All @@ -37,9 +36,6 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
Expand Down
20 changes: 1 addition & 19 deletions apps/support/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Disable built-in makefile rules for all apps to avoid pointless file-system
# scanning and general weirdness resulting from implicit rules.
# scanning and general weirdness resulting from implicit rules.
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

Expand Down Expand Up @@ -43,12 +43,7 @@ GENERATOR_OUTPUTS ?= static_library,h,registration,stmt,assembly
# This pulls in the definition of HALIDE_SYSTEM_LIBS and HALIDE_RTTI
include $(HALIDE_DISTRIB_PATH)/halide_config.make

ifeq ($(OS), Windows_NT)
# Flags for mingw environment
LDFLAGS += -lz -lole32 -lkernel32 -lpsapi -luuid -Wl,--stack,8388608
else
LDFLAGS += -ldl -lpthread -lz
endif

CXX ?= g++
GXX ?= g++
Expand Down Expand Up @@ -81,15 +76,11 @@ USE_EXPORT_DYNAMIC=
endif
endif

ifeq ($(OS), Windows_NT)
SHARED_EXT=dll
else
ifeq ($(UNAME), Darwin)
SHARED_EXT=dylib
else
SHARED_EXT=so
endif
endif

# To run apps on android that support this, build a separate toolchain from the Android NDK
# using the make-standalone-toolchain.sh script:
Expand Down Expand Up @@ -130,17 +121,8 @@ LDFLAGS-arm-32-android ?= -llog -fPIE -pie

LIB_HALIDE_STATIC = $(HALIDE_DISTRIB_PATH)/lib/libHalide.a

ifeq ($(OS), Windows_NT)

# TODO: copy libHalide.dll somewhere that windows can find it, and use it instead
LIB_HALIDE = $(LIB_HALIDE_STATIC)

else

LIB_HALIDE = $(HALIDE_DISTRIB_PATH)/bin/libHalide.$(SHARED_EXT)

endif

GENERATOR_DEPS ?= $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp
GENERATOR_DEPS_STATIC ?= $(LIB_HALIDE_STATIC) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp

Expand Down
1 change: 0 additions & 1 deletion halide.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ function(_halide_runtime_target_name HALIDE_TARGET OUTVAR)
profile
no_runtime
metal
mingw
c_plus_plus_name_mangling
large_buffers
hvx_64
Expand Down
6 changes: 0 additions & 6 deletions python_bindings/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ BIN ?= $(ROOT_DIR)/bin
PYTHON ?= python3
TEST_TMP ?= $(BIN)/tmp

ifeq ($(OS), Windows_NT)
# assume we are building for the MinGW environment
FPIC=
SHARED_EXT=dll
else
FPIC=-fPIC
ifeq ($(UNAME), Darwin)
SHARED_EXT=dylib
Expand All @@ -22,7 +17,6 @@ ifeq ($(UNAME), Darwin)
else
SHARED_EXT=so
endif
endif

ifeq ($(UNAME), Linux)
USE_EXPORT_DYNAMIC=-rdynamic
Expand Down
1 change: 0 additions & 1 deletion python_bindings/src/PyEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void define_enums(py::module &m) {
.value("Profile", Target::Feature::Profile)
.value("NoRuntime", Target::Feature::NoRuntime)
.value("Metal", Target::Feature::Metal)
.value("MinGW", Target::Feature::MinGW)
.value("CPlusPlusMangling", Target::Feature::CPlusPlusMangling)
.value("LargeBuffers", Target::Feature::LargeBuffers)
.value("HVX_64", Target::Feature::HVX_64)
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ set(RUNTIME_CPP
metal
metal_objc_arm
metal_objc_x86
mingw_math
mips_cpu_features
module_aot_ref_count
module_jit_ref_count
Expand Down
14 changes: 5 additions & 9 deletions src/CPlusPlusMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,15 @@ std::string simple_type_to_mangle_char(const std::string type_name, const Target
} else if (type_name == "int64_t") {
if (target.os == Target::OSX ||
target.os == Target::IOS ||
target.bits == 32 ||
target.has_feature(Target::MinGW)) {
target.bits == 32) {
return "x";
} else {
return "l";
}
} else if (type_name == "uint64_t") {
if (target.os == Target::OSX ||
target.os == Target::IOS ||
target.bits == 32 ||
target.has_feature(Target::MinGW)) {
target.bits == 32) {
return "y";
} else {
return "m";
Expand Down Expand Up @@ -537,8 +535,7 @@ std::string mangle_type(const Type &type, const Target &target, PrevPrefixes &pr
case 64:
if (target.os == Target::OSX ||
target.os == Target::IOS ||
target.bits == 32 ||
target.has_feature(Target::MinGW)) {
target.bits == 32) {
return "x";
} else {
return "l";
Expand All @@ -559,8 +556,7 @@ std::string mangle_type(const Type &type, const Target &target, PrevPrefixes &pr
case 64:
if (target.os == Target::OSX ||
target.os == Target::IOS ||
target.bits == 32 ||
target.has_feature(Target::MinGW)) {
target.bits == 32) {
return "y";
} else {
return "m";
Expand Down Expand Up @@ -608,7 +604,7 @@ std::string cplusplus_function_mangled_name(const std::string &name, const std::
std::string cplusplus_function_mangled_name(const std::string &name, const std::vector<std::string> &namespaces,
Type return_type, const std::vector<ExternFuncArgument> &args,
const Target &target) {
if (target.os == Target::Windows && !target.has_feature(Target::MinGW)) {
if (target.os == Target::Windows) {
return WindowsMangling::cplusplus_function_mangled_name(name, namespaces, return_type, args, target);
} else {
return ItaniumABIMangling::cplusplus_function_mangled_name(name, namespaces, return_type, args, target);
Expand Down
18 changes: 1 addition & 17 deletions src/LLVM_Runtime_Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ DECLARE_CPP_INITMOD(linux_host_cpu_count)
DECLARE_CPP_INITMOD(linux_yield)
DECLARE_CPP_INITMOD(matlab)
DECLARE_CPP_INITMOD(metadata)
DECLARE_CPP_INITMOD(mingw_math)
DECLARE_CPP_INITMOD(module_aot_ref_count)
DECLARE_CPP_INITMOD(module_jit_ref_count)
DECLARE_CPP_INITMOD(msan)
Expand Down Expand Up @@ -416,11 +415,7 @@ llvm::Triple get_triple_for_target(const Target &target) {
} else if (target.os == Target::Windows) {
triple.setVendor(llvm::Triple::PC);
triple.setOS(llvm::Triple::Win32);
if (target.has_feature(Target::MinGW)) {
triple.setEnvironment(llvm::Triple::GNU);
} else {
triple.setEnvironment(llvm::Triple::MSVC);
}
triple.setEnvironment(llvm::Triple::MSVC);
if (target.has_feature(Target::JIT)) {
// Use ELF for jitting
triple.setObjectFormat(llvm::Triple::ELF);
Expand Down Expand Up @@ -585,14 +580,6 @@ void link_modules(std::vector<std::unique_ptr<llvm::Module>> &modules, Target t,
vector<string> retain = {"__stack_chk_guard",
"__stack_chk_fail"};

if (t.has_feature(Target::MinGW)) {
retain.insert(retain.end(),
{"sincos", "sincosf",
"asinh", "asinhf",
"acosh", "acoshf",
"atanh", "atanhf"});
}

// Enumerate the global variables.
for (auto &gv : modules[0]->globals()) {
// No variables are part of the public interface (even the ones labelled halide_)
Expand Down Expand Up @@ -864,9 +851,6 @@ std::unique_ptr<llvm::Module> get_initial_module_for_target(Target t, llvm::LLVM
modules.push_back(get_initmod_windows_threads(c, bits_64, debug));
}
modules.push_back(get_initmod_windows_get_symbol(c, bits_64, debug));
if (t.has_feature(Target::MinGW)) {
modules.push_back(get_initmod_mingw_math(c, bits_64, debug));
}
} else if (t.os == Target::IOS) {
modules.push_back(get_initmod_posix_allocator(c, bits_64, debug));
modules.push_back(get_initmod_posix_error_handler(c, bits_64, debug));
Expand Down
5 changes: 2 additions & 3 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ namespace Internal {
// and in practice, it's extremely unlikely that anyone needs to rely on this
// being pure C output (vs possibly C++).
std::map<Output, OutputInfo> get_output_info(const Target &target) {
const bool is_windows_coff = target.os == Target::Windows &&
!target.has_feature(Target::MinGW);
const bool is_windows_coff = target.os == Target::Windows;
std::map<Output, OutputInfo> ext = {
{Output::assembly, {"assembly", ".s"}},
{Output::bitcode, {"bitcode", ".bc"}},
Expand Down Expand Up @@ -76,7 +75,7 @@ class TemporaryObjectFileDir final {
const std::string &suffix,
const Target &target,
bool in_front = false) {
const char *ext = (target.os == Target::Windows && !target.has_feature(Target::MinGW)) ? ".obj" : ".o";
const char *ext = (target.os == Target::Windows) ? ".obj" : ".o";
size_t slash_idx = base_path_name.rfind('/');
size_t backslash_idx = base_path_name.rfind('\\');
if (slash_idx == std::string::npos) {
Expand Down
Loading