Skip to content

Commit 9f5b651

Browse files
committed
make: del no-delete-null-pointer-checks for clang++
This PR enables the use of clang++ to compile C++ projects by adding `CXXUWFLAGS += -fno-delete-null-pointer-checks`, if `${CC}` understands `-fno-delete-null-pointer-checks` but `${CXX}` does not.
1 parent bf87d8f commit 9f5b651

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

Makefile.cflags

+22-13
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# Otherwise test if the compiler unterstands the "-std=gnu99" flag, and use it if so.
33
# Otherwise test if the compiler unterstands the "-std=c99" flag, and use it if so.
44
ifeq ($(filter -std=%,$(CFLAGS)),)
5-
ifeq ($(shell $(CC) -std=gnu99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
6-
CFLAGS += -std=gnu99
7-
else
8-
ifeq ($(shell $(CC) -std=c99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
9-
CFLAGS += -std=c99
10-
endif
11-
endif
5+
ifeq ($(shell $(CC) -std=gnu99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
6+
CFLAGS += -std=gnu99
7+
else
8+
ifeq ($(shell $(CC) -std=c99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
9+
CFLAGS += -std=c99
10+
endif
11+
endif
1212
endif
1313

1414
# Add `-fno-delete-null-pointer-checks` flag iff the compiler supports it.
@@ -17,18 +17,27 @@ endif
1717
# Right now clang does not use the *delete-null-pointer* optimization, and does not understand the parameter.
1818
# Related issues: #628, #664.
1919
ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
20-
ifeq ($(shell LANG=C $(CC) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
21-
CFLAGS += -fno-delete-null-pointer-checks
22-
endif
20+
ifeq ($(shell LANG=C $(CC) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
21+
CFLAGS += -fno-delete-null-pointer-checks
22+
23+
ifneq ($(shell $(CXX) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
24+
CXXUWFLAGS += -fno-delete-null-pointer-checks
25+
else
26+
ifneq ($(shell LANG=C $(CXX) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
27+
CXXUWFLAGS += -fno-delete-null-pointer-checks
28+
endif
29+
endif
30+
endif
2331
endif
2432

2533
# Fast-out on old style function definitions.
2634
# They cause unreadable error compiler errors on missing semicolons.
2735
# Worse yet they hide errors by accepting wildcard argument types.
2836
ifeq ($(shell $(CC) -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
29-
# duplicated parameters don't hurt
30-
CFLAGS += -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition
37+
# duplicated parameters don't hurt
38+
CFLAGS += -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition
39+
CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition
3140
endif
3241

3342
# Unwanted flags for c++
34-
CXXUWFLAGS += -std=gnu99 -std=c99 -Wstrict-prototypes -Wold-style-definition
43+
CXXUWFLAGS += -std=%

0 commit comments

Comments
 (0)