@@ -705,7 +705,7 @@ JLDFLAGS += $(SANITIZE_LDFLAGS)
705705endif # SANITIZE
706706
707707TAR := $(shell which gtar 2>/dev/null || which tar 2>/dev/null)
708- TAR_TEST := $(shell $(TAR ) --help 2>&1 | egrep 'bsdtar|strip-components')
708+ TAR_TEST := $(shell $(TAR ) --help 2>&1 | grep -E 'bsdtar|strip-components')
709709ifeq (,$(findstring components,$(TAR_TEST ) ) )
710710ifneq (bsdtar,$(findstring bsdtar,$(TAR_TEST ) ) )
711711$(error "please install either GNU tar or bsdtar")
@@ -772,6 +772,8 @@ else ifeq (cygwin, $(shell $(CC) -dumpmachine | cut -d\- -f3))
772772$(error "cannot build julia with cygwin-target compilers. set XC_HOST to i686-w64-mingw32 or x86_64-w64-mingw32 for mingw cross-compile")
773773else ifeq (msys, $(shell $(CC) -dumpmachine | cut -d\- -f3))
774774$(error "cannot build julia with msys-target compilers. please see the README.windows document for instructions on setting up mingw-w64 compilers")
775+ else ifneq (,$(findstring MSYS,$(shell uname)))
776+ $(error "cannot build julia from a msys shell. please launch a mingw shell instead by setting MSYSTEM=MINGW64")
775777endif
776778
777779ifeq ($(BUILD_OS ) ,Darwin)
@@ -1223,6 +1225,9 @@ else
12231225 NO_WHOLE_ARCHIVE := -Wl,--no-whole-archive
12241226endif
12251227
1228+ # Initialize these once, then add to them in OS-specific blocks
1229+ JLIBLDFLAGS :=
1230+
12261231ifeq ($(OS ) , Linux)
12271232OSLIBS += -Wl,--no-as-needed -ldl -lrt -lpthread -latomic -Wl,--export-dynamic,--as-needed,--no-whole-archive
12281233# Detect if ifunc is supported
@@ -1236,14 +1241,14 @@ ifneq ($(SANITIZE),1)
12361241JLDFLAGS += -Wl,-no-undefined
12371242endif
12381243ifeq (-Bsymbolic-functions, $(shell $(LD ) --help | grep -o -e "-Bsymbolic-functions") )
1239- JLIBLDFLAGS := -Wl,-Bsymbolic-functions
1240- else
1241- JLIBLDFLAGS :=
1244+ JLIBLDFLAGS += -Wl,-Bsymbolic-functions
1245+ endif
1246+ ifeq (--enable-new-dtags, $(shell $(LD ) --help | grep -o -e "--enable-new-dtags") )
1247+ JLIBLDFLAGS += -Wl,--enable-new-dtags
12421248endif
1249+
12431250# Linker doesn't detect automatically that Julia doesn't need executable stack
12441251JLIBLDFLAGS += -Wl,-z,noexecstack
1245- else ifneq ($(OS), Darwin)
1246- JLIBLDFLAGS :=
12471252endif
12481253
12491254ifeq ($(OS ) , FreeBSD)
@@ -1266,7 +1271,7 @@ OSLIBS += -framework CoreFoundation
12661271WHOLE_ARCHIVE := -Xlinker -all_load
12671272NO_WHOLE_ARCHIVE :=
12681273HAVE_SSP := 1
1269- JLIBLDFLAGS : = -Wl,-compatibility_version,$(SOMAJOR ) -Wl,-current_version,$(JULIA_MAJOR_VERSION ) .$(JULIA_MINOR_VERSION ) .$(JULIA_PATCH_VERSION )
1274+ JLIBLDFLAGS + = -Wl,-compatibility_version,$(SOMAJOR ) -Wl,-current_version,$(JULIA_MAJOR_VERSION ) .$(JULIA_MINOR_VERSION ) .$(JULIA_PATCH_VERSION )
12701275endif
12711276
12721277ifeq ($(OS ) , WINNT)
@@ -1368,7 +1373,6 @@ CLANGSA_FLAGS :=
13681373CLANGSA_CXXFLAGS :=
13691374ifeq ($(OS ) , Darwin) # on new XCode, the files are hidden
13701375CLANGSA_FLAGS += -isysroot $(shell xcode-select -p) /Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
1371- CLANGSA_CXXFLAGS += -isystem $(shell xcode-select -p) /Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
13721376endif
13731377ifeq ($(USEGCC ) ,1)
13741378# try to help clang find the c++ files for CC by guessing the value for --prefix
@@ -1394,13 +1398,13 @@ define symlink_target # (from, to-dir, to-name)
13941398CLEAN_TARGETS += clean-$$(abspath $(2 ) /$(3 ) )
13951399clean-$$(abspath $(2 ) /$(3 ) ) :
13961400ifeq ($(BUILD_OS ) , WINNT)
1397- -cmd //C rmdir $$(call mingw_to_dos ,$(2)/$(3),cd $(2) && )
1401+ -cmd //C rmdir $$(call cygpath_w ,$(2)/$(3))
13981402else
13991403 rm -rf $$(abspath $(2)/$(3))
14001404endif
14011405$$(abspath $(2 ) /$(3 ) ) : | $$(abspath $(2 ) )
14021406ifeq ($$(BUILD_OS ) , WINNT)
1403- @cmd //C mklink //J $$(call mingw_to_dos ,$(2)/$(3),cd $(2) &&) $$(call mingw_to_dos ,$(1), )
1407+ @cmd //C mklink //J $$(call cygpath_w ,$(2)/$(3)) $$(call cygpath_w ,$(1))
14041408else ifneq (,$$(findstring CYGWIN,$$(BUILD_OS)))
14051409 @cmd /C mklink /J $$(call cygpath_w,$(2)/$(3)) $$(call cygpath_w,$(1))
14061410else ifdef JULIA_VAGRANT_BUILD
@@ -1418,7 +1422,7 @@ WINE ?= wine
14181422# many of the following targets must be = not := because the expansion of the makefile functions (and $1) shouldn't happen until later
14191423ifeq ($(BUILD_OS ) , WINNT) # MSYS
14201424spawn = $(1 )
1421- cygpath_w = $(1 )
1425+ cygpath_w = ` cygpath -w $( 1) `
14221426else ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # Cygwin
14231427spawn = $(1 )
14241428cygpath_w = ` cygpath -w $( 1) `
0 commit comments