[Bug 230517] lang/dmd2: compile error: "[-Wc++11-narrowing]"
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Fri Aug 10 23:48:10 UTC 2018
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230517
Bug ID: 230517
Summary: lang/dmd2: compile error: "[-Wc++11-narrowing]"
Product: Ports & Packages
Version: Latest
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: Individual Port(s)
Assignee: cy at FreeBSD.org
Reporter: higuchi at jt-sys.co.jp
Assignee: cy at FreeBSD.org
Flags: maintainer-feedback?(cy at FreeBSD.org)
* Problem 1
clang++ stops at "[-Wc++11-narrowing]" error.
(I think this is a bad behavior of clang++. I want report only.)
Log
========
c++ -m64 -c -Wno-deprecated -Wstrict-aliasing -fno-exceptions -fno-rtti
-D__pasc
al= -DMARS=1 -DTARGET_FREEBSD=1 -DDM_TARGET_CPU_X86=1 -DDMDV2=1 -O2 -DDMDV2=1
-
Iroot -Itk -Ibackend -I. -MMD -MF go.deps backend/go.c
backend/go.c:80:11: error: constant expression evaluates to -1 which cannot be
narrowed to type 'mftype' (aka 'unsigned int') [-Wc++11-narrowing]
{ 0,MFall,MFcnp,MFcp,MFcse,MFda,MFdc,MFdv,MFli,MFliv,MFlocal,MFloop,
^~~~~
backend/go.h:39:17: note: expanded from macro 'MFall'
#define MFall (~0) // do everything
^~~~
backend/go.c:80:11: note: insert an explicit cast to silence this issue
{ 0,MFall,MFcnp,MFcp,MFcse,MFda,MFdc,MFdv,MFli,MFliv,MFlocal,MFloop,
^~~~~
static_cast<mftype>( )
backend/go.h:39:17: note: expanded from macro 'MFall'
#define MFall (~0) // do everything
^~~~
backend/go.c:123:18: error: case value evaluates to -1, which cannot be
narrowed
to type 'unsigned int' [-Wc++11-narrowing]
case -1: /* not in flagtab[] */
^
backend/go.c:157:18: error: case value evaluates to -1, which cannot be
narrowed
to type 'unsigned int' [-Wc++11-narrowing]
case -1: /* not in flagtab[] */
^
3 errors generated.
gmake[3]: *** [posix.mak:384: go.o] Error 1
gmake[3]: Leaving directory
'/usr/ports/lang/dmd2/work/.host_dmd-2.067.1/dmd2/sr
c/dmd'
*** Error code 2
Stop.
make[2]: stopped in /usr/ports/lang/dmd2
*** Error code 1
Stop.
make[1]: stopped in /usr/ports/lang/dmd2
*** Error code 1
Stop.
make: stopped in /usr/ports/lang/dmd2
========
So, we have to add "-Wno-c++11-narrowing" to compile flags.
* Problem 2
Makefile replaces "g++" to "c++" too much.
lang/dmd2/Makefile
========
@${REINPLACE_CMD} -e "s|g++|${CXX}|" \
-e "s|/etc|${PREFIX}/etc|" \
${WRKSRC}/dmd/src/posix.mak
========
This replaces "clang++" to "clanc++".
ifeq ($(HOST_CC), clang++)
|
v
ifeq ($(HOST_CC), clanc++)
We have to replace default compiler only.
========
@${REINPLACE_CMD} -e "s|HOST_CC=g++|HOST_CC=${CXX}|" \
========
* Problem 3
After replacing, $(HOST_CC) is "c++", so this doesn't match to "clang++"
This causes lack of compile option.
========
ifeq ($(HOST_CC), clang++)
========
But we know that c++ of FreeBSD (>=10) is always clang++.
So, we can replace "clang++" to "c++". (adhoc solution)
Importing determine compiler type from dmd/src/posix.mak to
.host_dmd-2.067.1/dmd2/src/dmd/posix.mak is the best solution.
But it is too much code.
========
# determine whether CXX is gcc or clang based
CXX_VERSION:=$(shell $(CXX) --version)
ifneq (,$(findstring g++,$(CXX_VERSION))$(findstring
gcc,$(CXX_VERSION))$(findstring GCC,$(CXX_VERSION)))
CXX_KIND=g++
endif
ifneq (,$(findstring clang,$(CXX_VERSION)))
CXX_KIND=clang++
endif
========
* Solution
========
diff -uprN dmd2.org/Makefile dmd2/Makefile
--- dmd2.org/Makefile 2017-11-30 15:13:34.000000000 +0900
+++ dmd2/Makefile 2018-08-11 04:18:33.133369000 +0900
@@ -60,7 +60,8 @@ MAKE_ARGS+= DEBUG_FLAGS=-g\ -DDEBUG=1\ -
MODULEDIR= ${PREFIX}/include/d/phobos2
post-patch:
- @${REINPLACE_CMD} -e "s|g++|${CXX}|" \
+ @${REINPLACE_CMD} -e "s|HOST_CXX=g++|HOST_CXX=${CXX}|" \
+ -e
"s|-Wno-logical-op-parentheses|-Wno-logical-op-parentheses
-Wno-c++11-narrowing|" \
-e "s|/etc|${PREFIX}/etc|" \
${WRKSRC}/dmd/src/posix.mak
@${REINPLACE_CMD} -e "s|gcc|${CC}|" ${WRKSRC}/dmd/src/link.d
diff -uprN dmd2.org/Makefile.bootstrap dmd2/Makefile.bootstrap
--- dmd2.org/Makefile.bootstrap 2017-02-14 15:27:28.000000000 +0900
+++ dmd2/Makefile.bootstrap 2018-08-11 04:24:33.011166000 +0900
@@ -38,7 +38,10 @@ MODEL= 32
MODULEDIR= ${PREFIX}/include/d/phobos2
post-patch:
- @${REINPLACE_CMD} -e "s|g++|${CXX}|" ${WRKSRC}/posix.mak
+ @${REINPLACE_CMD} -e "s|HOST_CC=g++|HOST_CC=${CXX}|" \
+ -e "s|clang++|c++|" \
+ -e
"s|-Wno-logical-op-parentheses|-Wno-logical-op-parentheses
-Wno-c++11-narrowing|" \
+ ${WRKSRC}/posix.mak
@${REINPLACE_CMD} -e "s|cc|${CC}|" ${WRKSRC}/../phobos/posix.mak
@${REINPLACE_CMD} -e "s|/etc|${PREFIX}/etc|" \
-e "s|\(dmd\)|\12|gI" \
========
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-ports-bugs
mailing list