Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2018 23:48:07 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 230517] lang/dmd2: compile error: "[-Wc++11-narrowing]"
Message-ID:  <bug-230517-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D230517

            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@FreeBSD.org
          Reporter: higuchi@jt-sys.co.jp
          Assignee: cy@FreeBSD.org
             Flags: maintainer-feedback?(cy@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
=3D=3D=3D=3D=3D=3D=3D=3D
c++ -m64 -c -Wno-deprecated -Wstrict-aliasing -fno-exceptions -fno-rtti
-D__pasc
al=3D -DMARS=3D1 -DTARGET_FREEBSD=3D1 -DDM_TARGET_CPU_X86=3D1 -DDMDV2=3D1  =
-O2 -DDMDV2=3D1
-
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
=3D=3D=3D=3D=3D=3D=3D=3D

So, we have to add "-Wno-c++11-narrowing" to compile flags.


* Problem 2

Makefile replaces "g++" to "c++" too much.

lang/dmd2/Makefile
=3D=3D=3D=3D=3D=3D=3D=3D
       @${REINPLACE_CMD} -e "s|g++|${CXX}|" \
                          -e "s|/etc|${PREFIX}/etc|" \
                ${WRKSRC}/dmd/src/posix.mak
=3D=3D=3D=3D=3D=3D=3D=3D

This replaces "clang++" to "clanc++".

ifeq ($(HOST_CC), clang++)
|
v
ifeq ($(HOST_CC), clanc++)

We have to replace default compiler only.
=3D=3D=3D=3D=3D=3D=3D=3D
       @${REINPLACE_CMD} -e "s|HOST_CC=3Dg++|HOST_CC=3D${CXX}|" \
=3D=3D=3D=3D=3D=3D=3D=3D


* Problem 3

After replacing, $(HOST_CC) is "c++", so this doesn't match to "clang++"=20
This causes lack of compile option.
=3D=3D=3D=3D=3D=3D=3D=3D
ifeq ($(HOST_CC), clang++)
=3D=3D=3D=3D=3D=3D=3D=3D

But we know that c++ of FreeBSD (>=3D10) 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.
=3D=3D=3D=3D=3D=3D=3D=3D
# determine whether CXX is gcc or clang based
CXX_VERSION:=3D$(shell $(CXX) --version)
ifneq (,$(findstring g++,$(CXX_VERSION))$(findstring
gcc,$(CXX_VERSION))$(findstring GCC,$(CXX_VERSION)))
        CXX_KIND=3Dg++
endif
ifneq (,$(findstring clang,$(CXX_VERSION)))
        CXX_KIND=3Dclang++
endif
=3D=3D=3D=3D=3D=3D=3D=3D


* Solution

=3D=3D=3D=3D=3D=3D=3D=3D
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+=3D   DEBUG_FLAGS=3D-g\ -DDEBUG=3D1\ -
 MODULEDIR=3D     ${PREFIX}/include/d/phobos2

 post-patch:
-       @${REINPLACE_CMD} -e "s|g++|${CXX}|" \
+       @${REINPLACE_CMD} -e "s|HOST_CXX=3Dg++|HOST_CXX=3D${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=3D               32
 MODULEDIR=3D     ${PREFIX}/include/d/phobos2

 post-patch:
-       @${REINPLACE_CMD} -e "s|g++|${CXX}|" ${WRKSRC}/posix.mak
+       @${REINPLACE_CMD} -e "s|HOST_CC=3Dg++|HOST_CC=3D${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"         \
=3D=3D=3D=3D=3D=3D=3D=3D

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-230517-7788>