Makefile: some cleanups / added VERBOSE option - #4438
Conversation
…Cygwin/MinGW detection / added `VERBOSE=1` to Cygwin and MinGW CI builds
|
MinGW CI: Cygwin CI: @chrfranke |
The Cygwin detection is broken. It is guarded by Build works anyway because the workaround Using Reliable ways to detect Cygwin are for example: or Note that this detection is wrong if Cygwin is used to build a non-Cygwin version of (If Cygwin is installed, MSYS is not needed!) In general, typical cross compile scenarios like MinGW-w64 builds on Linux are not handled by the Makefile as it only detects the build platform but not the target platform. |
|
@chrfranke So the Cygwin detection is broken, the workarounds are not being used at all and the application "just works". So we can just bin them along with the detection. Great. I have tested MinGW ( Now I just need to do some final tests with the I will put those changes into a follow-up PR. I will CC you on it. I will also look into cross-compiling since with FYI |
|
Cygwin detection may still make sense due to the stack size workaround which apparently only affects certain use cases: ifdef CYGWIN
...
# Set the flag to address compile time warnings
# with tinyxml2 and Cygwin.
CPPFLAGS+=-U__STRICT_ANSI__ <=== remove this
# Increase stack size for Cygwin builds to avoid segmentation fault in limited recursive tests.
CXXFLAGS+=-Wl,--stack,8388608 <=== keep this
endif # CYGWIN
Indeed, sorry for the noise. I forgot that the Cygwin DLL unconditionally converts certain variables to uppercase, see environ.cc. Regarding cross compiling, the following logic may be a first start: If A more elaborate approach would be to guess the target platform from CXX = g++
UNAME_S := $(shell uname -s 2>/dev/null)
# Platform uname -s uname -o BUILD_HOST
# ============================================================
# Debian, ... Linux GNU/Linux linux
# Cygwin CYGWIN_<WINVER> Cygwin cygwin
# MSYS MINGW32_<WINVER> Msys mingw32
# Debian kFreeBSD GNU/kFreeBSD? GNU/kFreeBSD? kfreebsd
# FreeBSD FreeBSD FreeBSD freebsd
# MacOS/Darwin Darwin ? darwin
BUILD_HOST := $(shell echo "$(UNAME_S)" | \
tr A-Z a-z | sed -e 's/_.*$$//' -e 's/^gnu\///' \
)
# x86_64 target CXX for cross-compiler TARGET_HOST
# =====================================================================
# Linux x86_64-linux-gnu-g++ linux
# Cygwin x86_64-pc-cygwin-g++ cygwin
# MinGW-w64 x86_64-w64-mingw32-g++ mingw32
# FreeBSD 13 clang++ --target=x86_64-unknown-freebsd13 freebsd
# MacOS/Darwin ? ?
ifneq ($(findstring -,$(CXX)),)
TARGET_HOST := $(shell echo "$(CXX)" | \
sed -e 's/^.*--target=\([^ ]*\).*$$/\1/' \
-e 's/-linux-gnu/-gnu-linux/' -e 's/bsd[0-9]*/bsd/' | \
sed -n -e 's/^ *[^- ][^- ]*-[^- ][^- ]*-\([^- ][^- ]*\).*$$/\1/p' \
)
endif
ifeq ($(TARGET_HOST),)
TARGET_HOST := $(BUILD_HOST)
endif
all:
@echo "uname -s: '$(UNAME_S)'"
@echo "CXX: '$(CXX)'"
@echo "BUILD_HOST: '$(BUILD_HOST)'"
@echo "TARGET_HOST: '$(TARGET_HOST)'"
test:
@echo "=== Linux build ==="
$(MAKE) UNAME_S=Linux
@echo "=== Cygwin build ==="
$(MAKE) UNAME_S=CYGWIN_NT-10.0-19044
@echo "=== MinGW-w64 build ==="
$(MAKE) UNAME_S=MINGW32_NT-10.0-19044
@echo "=== MinGW-w64 build on Cygwin ==="
$(MAKE) UNAME_S=CYGWIN_NT-10.0-19044 CXX=x86_64-w64-mingw32-g++
@echo "=== MinGW-w64 build on Linux ==="
$(MAKE) UNAME_S=Linux CXX=x86_64-w64-mingw32-g++
@echo "=== FreeBSD build on Linux ==="
$(MAKE) UNAME_S=Linux CXX='clang++ --target=x86_64-unknown-freebsd13' |
As it seems that the workaround was never used (at least not for several years - seems like the Cygwin workarounds were targets at a decade-old version) I see no point in keep it without having an actual case.
No noise at all. Thanks for the pointer - something to consider for more tests. That was just an FYI since I didn't know that and the comments indicate that this is used as a Windows detection when it actually was a shell detection.
Thanks a lot again for that awesome research. I was thinking more in terms of existing cross-compile use cases. So it appears there might be none and we should not be adding features to the
So for cross-compiling I would point people to CMake instead. It's already necessary for the packaging builds which do not use system dependencies (which are not 100% correct as I just stumbled into with macos). And it seems it is already working since there are packages for other architectures. And if something doesn't work the packagers usually point that out fast and I also try to give them heads up when something changes so we don't have to fix post-release. I understand people have preferences and there's reasons to keep |
That is fine for me. |
Great. I will try to improve the documentation as well when I look into it. |
CPPFLAGSis the variable for preprocessor options - see http://porthos.ist.utl.pt/docs/make/make_97.html.A cleanup and fixes to the MinGW/Cygwin detection will follow in a separate PR.
We should use implicit rules instead of specifying our own. Something to look at for later.