Skip to content

Commit

Permalink
Fix ln_args parsing bug on MSYS2 (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Carter authored Mar 13, 2023
1 parent 7d1b562 commit f805d30
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 16 deletions.
18 changes: 17 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32520/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -224,7 +229,18 @@ endif
# Add the include file paths to AFLAGS and CFLAGS.
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif


################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32570/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -276,7 +281,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32572/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -259,7 +264,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32650/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -261,7 +266,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32655/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -261,7 +266,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32660/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -261,7 +266,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32662/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -261,7 +266,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32665/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -251,7 +256,17 @@ endif
# Add the include file paths to AFLAGS and CFLAGS.
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32670/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -258,7 +263,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
17 changes: 16 additions & 1 deletion Libraries/CMSIS/Device/Maxim/MAX32672/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -258,7 +263,17 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
ifneq ($(MSYS),)
# 2-27-2023: This workaround was added to resolve a linker bug introduced
# when we started using ln_args.txt. The GCC linker expects C:/-like paths
# on Windows if arguments are passed in from a text file. However, ln_args
# is parsed through a regex that misses the edge case -L/C/Path/... because
# of the leading "-L". We use cygpath here to handle that edge case before
# parsing ln_args.txt.
LDFLAGS+=${patsubst %,-L%,$(shell cygpath -m $(LIBPATH))}
else
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
16 changes: 14 additions & 2 deletions Libraries/CMSIS/Device/Maxim/MAX32675/Source/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ endif
# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC
# will be converted from /cygdrive/c to C:.
################################################################################
ifneq ($(findstring CYGWIN, ${shell uname -s}), )
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

# Get the prefix for the tools to use.
ifeq "$(TOOL_DIR)" ""
PREFIX=arm-none-eabi
Expand Down Expand Up @@ -258,7 +263,14 @@ endif
AFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
CXXFLAGS+=${patsubst %,-I%,$(call fixpath,$(IPATH))}
LDFLAGS+=${patsubst %,-L%,$(call fixpath,$(LIBPATH))}
UNAME := $(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)), )
CYGWIN=True
endif

ifneq ($(findstring MSYS, $(UNAME)), )
MSYS=True
endif

################################################################################
# The rule for building the object file from each C source file.
Expand Down
Loading

0 comments on commit f805d30

Please sign in to comment.