Skip to content

Commit f805d30

Browse files
authored
Fix ln_args parsing bug on MSYS2 (#479)
1 parent 7d1b562 commit f805d30

File tree

15 files changed

+239
-16
lines changed

15 files changed

+239
-16
lines changed

Libraries/CMSIS/Device/Maxim/MAX32520/Source/GCC/gcc.mk

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -224,7 +229,18 @@ endif
224229
# Add the include file paths to AFLAGS and CFLAGS.
225230
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
226231
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
232+
ifneq ($(MSYS),)
233+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
234+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
235+
# on Windows if arguments are passed in from a text file. However, ln_args
236+
# is parsed through a regex that misses the edge case -L/C/Path/... because
237+
# of the leading "-L". We use cygpath here to handle that edge case before
238+
# parsing ln_args.txt.
239+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
240+
else
227241
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
242+
endif
243+
228244

229245
################################################################################
230246
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32570/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@ endif
9595
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9696
# will be converted from /cygdrive/c to C:.
9797
################################################################################
98-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
98+
UNAME := $(shell uname -s)
99+
ifneq ($(findstring CYGWIN, $(UNAME)), )
99100
CYGWIN=True
100101
endif
101102

103+
ifneq ($(findstring MSYS, $(UNAME)), )
104+
MSYS=True
105+
endif
106+
102107
# Get the prefix for the tools to use.
103108
ifeq "$(TOOL_DIR)" ""
104109
PREFIX=arm-none-eabi
@@ -276,7 +281,17 @@ endif
276281
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
277282
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
278283
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
284+
ifneq ($(MSYS),)
285+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
286+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
287+
# on Windows if arguments are passed in from a text file. However, ln_args
288+
# is parsed through a regex that misses the edge case -L/C/Path/... because
289+
# of the leading "-L". We use cygpath here to handle that edge case before
290+
# parsing ln_args.txt.
291+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
292+
else
279293
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
294+
endif
280295

281296
################################################################################
282297
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32572/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@ endif
9595
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9696
# will be converted from /cygdrive/c to C:.
9797
################################################################################
98-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
98+
UNAME := $(shell uname -s)
99+
ifneq ($(findstring CYGWIN, $(UNAME)), )
99100
CYGWIN=True
100101
endif
101102

103+
ifneq ($(findstring MSYS, $(UNAME)), )
104+
MSYS=True
105+
endif
106+
102107
# Get the prefix for the tools to use.
103108
ifeq "$(TOOL_DIR)" ""
104109
PREFIX=arm-none-eabi
@@ -259,7 +264,17 @@ endif
259264
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
260265
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
261266
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
267+
ifneq ($(MSYS),)
268+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
269+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
270+
# on Windows if arguments are passed in from a text file. However, ln_args
271+
# is parsed through a regex that misses the edge case -L/C/Path/... because
272+
# of the leading "-L". We use cygpath here to handle that edge case before
273+
# parsing ln_args.txt.
274+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
275+
else
262276
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
277+
endif
263278

264279
################################################################################
265280
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32650/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -261,7 +266,17 @@ endif
261266
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
262267
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
263268
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
269+
ifneq ($(MSYS),)
270+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
271+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
272+
# on Windows if arguments are passed in from a text file. However, ln_args
273+
# is parsed through a regex that misses the edge case -L/C/Path/... because
274+
# of the leading "-L". We use cygpath here to handle that edge case before
275+
# parsing ln_args.txt.
276+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
277+
else
264278
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
279+
endif
265280

266281
################################################################################
267282
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32655/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@ endif
9595
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9696
# will be converted from /cygdrive/c to C:.
9797
################################################################################
98-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
98+
UNAME := $(shell uname -s)
99+
ifneq ($(findstring CYGWIN, $(UNAME)), )
99100
CYGWIN=True
100101
endif
101102

103+
ifneq ($(findstring MSYS, $(UNAME)), )
104+
MSYS=True
105+
endif
106+
102107
# Get the prefix for the tools to use.
103108
ifeq "$(TOOL_DIR)" ""
104109
PREFIX=arm-none-eabi
@@ -261,7 +266,17 @@ endif
261266
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
262267
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
263268
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
269+
ifneq ($(MSYS),)
270+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
271+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
272+
# on Windows if arguments are passed in from a text file. However, ln_args
273+
# is parsed through a regex that misses the edge case -L/C/Path/... because
274+
# of the leading "-L". We use cygpath here to handle that edge case before
275+
# parsing ln_args.txt.
276+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
277+
else
264278
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
279+
endif
265280

266281
################################################################################
267282
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32660/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -261,7 +266,17 @@ endif
261266
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
262267
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
263268
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
269+
ifneq ($(MSYS),)
270+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
271+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
272+
# on Windows if arguments are passed in from a text file. However, ln_args
273+
# is parsed through a regex that misses the edge case -L/C/Path/... because
274+
# of the leading "-L". We use cygpath here to handle that edge case before
275+
# parsing ln_args.txt.
276+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
277+
else
264278
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
279+
endif
265280

266281
################################################################################
267282
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32662/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -261,7 +266,17 @@ endif
261266
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
262267
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
263268
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
269+
ifneq ($(MSYS),)
270+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
271+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
272+
# on Windows if arguments are passed in from a text file. However, ln_args
273+
# is parsed through a regex that misses the edge case -L/C/Path/... because
274+
# of the leading "-L". We use cygpath here to handle that edge case before
275+
# parsing ln_args.txt.
276+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
277+
else
264278
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
279+
endif
265280

266281
################################################################################
267282
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32665/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@ endif
9595
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9696
# will be converted from /cygdrive/c to C:.
9797
################################################################################
98-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
98+
UNAME := $(shell uname -s)
99+
ifneq ($(findstring CYGWIN, $(UNAME)), )
99100
CYGWIN=True
100101
endif
101102

103+
ifneq ($(findstring MSYS, $(UNAME)), )
104+
MSYS=True
105+
endif
106+
102107
# Get the prefix for the tools to use.
103108
ifeq "$(TOOL_DIR)" ""
104109
PREFIX=arm-none-eabi
@@ -251,7 +256,17 @@ endif
251256
# Add the include file paths to AFLAGS and CFLAGS.
252257
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
253258
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
259+
ifneq ($(MSYS),)
260+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
261+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
262+
# on Windows if arguments are passed in from a text file. However, ln_args
263+
# is parsed through a regex that misses the edge case -L/C/Path/... because
264+
# of the leading "-L". We use cygpath here to handle that edge case before
265+
# parsing ln_args.txt.
266+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
267+
else
254268
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
269+
endif
255270

256271
################################################################################
257272
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32670/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -258,7 +263,17 @@ endif
258263
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
259264
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
260265
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
266+
ifneq ($(MSYS),)
267+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
268+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
269+
# on Windows if arguments are passed in from a text file. However, ln_args
270+
# is parsed through a regex that misses the edge case -L/C/Path/... because
271+
# of the leading "-L". We use cygpath here to handle that edge case before
272+
# parsing ln_args.txt.
273+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
274+
else
261275
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
276+
endif
262277

263278
################################################################################
264279
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32672/Source/GCC/gcc.mk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -258,7 +263,17 @@ endif
258263
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
259264
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
260265
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
266+
ifneq ($(MSYS),)
267+
# 2-27-2023: This workaround was added to resolve a linker bug introduced
268+
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
269+
# on Windows if arguments are passed in from a text file. However, ln_args
270+
# is parsed through a regex that misses the edge case -L/C/Path/... because
271+
# of the leading "-L". We use cygpath here to handle that edge case before
272+
# parsing ln_args.txt.
273+
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
274+
else
261275
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
276+
endif
262277

263278
################################################################################
264279
# The rule for building the object file from each C source file.

Libraries/CMSIS/Device/Maxim/MAX32675/Source/GCC/gcc.mk

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ endif
9292
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
9393
# will be converted from /cygdrive/c to C:.
9494
################################################################################
95-
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
95+
UNAME := $(shell uname -s)
96+
ifneq ($(findstring CYGWIN, $(UNAME)), )
9697
CYGWIN=True
9798
endif
9899

100+
ifneq ($(findstring MSYS, $(UNAME)), )
101+
MSYS=True
102+
endif
103+
99104
# Get the prefix for the tools to use.
100105
ifeq "$(TOOL_DIR)" ""
101106
PREFIX=arm-none-eabi
@@ -258,7 +263,14 @@ endif
258263
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
259264
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
260265
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
261-
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
266+
UNAME := $(shell uname -s)
267+
ifneq ($(findstring CYGWIN, $(UNAME)), )
268+
CYGWIN=True
269+
endif
270+
271+
ifneq ($(findstring MSYS, $(UNAME)), )
272+
MSYS=True
273+
endif
262274

263275
################################################################################
264276
# The rule for building the object file from each C source file.

0 commit comments

Comments
 (0)