Bug 230502

Summary: games/flightgear: fails to build with clang 7
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Ganael LAPLANCHE <martymac>
Status: Closed FIXED    
Severity: Affects Only Me Keywords: needs-patch
Priority: --- Flags: bugzilla: maintainer-feedback? (martymac)
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 230355    
Attachments:
Description Flags
First patch attempt none

Description Jan Beich freebsd_committer freebsd_triage 2018-08-10 13:14:25 UTC
$ poudriere jail -cj clang7 -a amd64 -v projects/clang700-import -m svn+https
$ poudriere testport -j clang7 games/flightgear
[...]
src/AIModel/AIFlightPlanCreatePushBack.cxx:96:48: error: ordered comparison between pointer and zero ('FGTaxiNode *' and 'int')
    if (parking && parking->getPushBackPoint() > 0) {
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~

buid log: https://ptpb.pw/QTXC
Comment 1 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-08-11 16:24:52 UTC
Thanks for your report.

I'll be able to take a look at this within one or two weeks.

Best regards,
Ganael.
Comment 2 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-08-20 20:36:55 UTC
Created attachment 196400 [details]
First patch attempt
Comment 3 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-08-20 20:37:26 UTC
Hi Jan,

Unfortunately my poudriere box is still running 11.2 and building packages for 12-CURRENT does not work anymore (python 2.7 cannot be built).

Would the attached patch be enough to fix the problem ?
Comment 4 Jan Beich freebsd_committer freebsd_triage 2018-08-20 22:50:05 UTC
Comment on attachment 196400 [details]
First patch attempt

In file included from src/FDM/UIUCModel/uiuc_gear.cpp:72:
In file included from src/FDM/UIUCModel/uiuc_gear.h:4:
In file included from src/FDM/UIUCModel/uiuc_aircraft.h:150:
src/FDM/UIUCModel/uiuc_parsefile.h:26:17: error: reference to 'stack' is ambiguous
                stack commands;
                ^
src/FDM/UIUCModel/uiuc_parsefile.h:20:22: note: candidate found by name lookup is 'stack'
typedef list<string> stack; //list to contain the input file "command_lines"
                     ^
/usr/include/c++/v1/stack:113:28: note: candidate found by name lookup is 'std::__1::stack'
class _LIBCPP_TEMPLATE_VIS stack
                           ^
In file included from src/FDM/UIUCModel/uiuc_gear.cpp:72:
In file included from src/FDM/UIUCModel/uiuc_gear.h:4:
In file included from src/FDM/UIUCModel/uiuc_aircraft.h:150:
src/FDM/UIUCModel/uiuc_parsefile.h:40:17: error: reference to 'stack' is ambiguous
                stack getCommands();
                ^
src/FDM/UIUCModel/uiuc_parsefile.h:20:22: note: candidate found by name lookup is 'stack'
typedef list<string> stack; //list to contain the input file "command_lines"
                     ^
/usr/include/c++/v1/stack:113:28: note: candidate found by name lookup is 'std::__1::stack'
class _LIBCPP_TEMPLATE_VIS stack
                           ^
In file included from src/FDM/UIUCModel/uiuc_gear.cpp:72:
In file included from src/FDM/UIUCModel/uiuc_gear.h:4:
src/FDM/UIUCModel/uiuc_aircraft.h:153:9: error: reference to 'stack' is ambiguous
typedef stack :: iterator LIST;
        ^
src/FDM/UIUCModel/uiuc_parsefile.h:20:22: note: candidate found by name lookup is 'stack'
typedef list<string> stack; //list to contain the input file "command_lines"
                     ^
/usr/include/c++/v1/stack:113:28: note: candidate found by name lookup is 'std::__1::stack'
class _LIBCPP_TEMPLATE_VIS stack
                           ^
In file included from src/FDM/UIUCModel/uiuc_gear.cpp:72:
In file included from src/FDM/UIUCModel/uiuc_gear.h:4:
src/FDM/UIUCModel/uiuc_aircraft.h:153:18: error: use of class template 'iterator' requires template arguments
typedef stack :: iterator LIST;
                 ^
/usr/include/c++/v1/iterator:521:29: note: template is declared here
struct _LIBCPP_TEMPLATE_VIS iterator
                            ^
4 errors generated.

build log: https://ptpb.pw/L7aF
Comment 5 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-08-28 10:07:36 UTC
Hi Jan,

As I am not able to run a poudriere build on -CURRENT, I have tried to reproduce the build problem using clang 7 from *ports* on 10.4/i386 and 11.2/amd64 by adding a dependency to the port and settinf CPP/CC/CXX variables.

Unfortunately, flightgear builds fine on 11.2, see logs :

http://box.martymac.org/FreeBSD-Packages/data/FBSD112amd64-default/2018-08-27_19h12m17s/logs/flightgear-2018.2.1_2.log

On 10.4/i386, compilation fails with another error than yours :

http://box.martymac.org/FreeBSD-Packages/data/FBSD104i386-default/2018-08-27_18h59m25s/logs/errors/flightgear-2018.2.1_2.log

I presume those differences come from base path still being included for headers and libraries.

Are you aware of an easy way to reproduce the build problem on 10.4 or 11.2 ?

Best regards,

Ganael.
Comment 6 Jan Beich freebsd_committer freebsd_triage 2018-08-28 14:10:26 UTC
(In reply to Ganael LAPLANCHE from comment #5)
> http://box.martymac.org/FreeBSD-Packages/data/FBSD112amd64-default/2018-08-27_19h12m17s/logs/flightgear-2018.2.1_2.log
[...]
> CC="gcc7" ... CPP="cpp7" ... CXX="g++7

What? Better replace 40 with 70 in the following conditional. See my build log: https://ptpb.pw/C3Bv (11.2 amd64)

  .if ${COMPILER_TYPE} == clang && ${COMPILER_VERSION} < 40
  BUILD_DEPENDS+=	${LOCALBASE}/bin/clang40:devel/llvm40
  CPP=	${LOCALBASE}/bin/clang-cpp40
  CC=	${LOCALBASE}/bin/clang40
  CXX=	${LOCALBASE}/bin/clang++40
  .endif

Note, the above conditional can be replaced with USES=compiler:c++14-lang where it'd be the subject to bug 230790.
Note2, according my build log llvm70 can also be pulled via mesa-libs per bug 230789.
Comment 7 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-08-28 15:04:00 UTC
Weird... If you look further in the logs, you'll see that /usr/local/bin/clang++70 is used. Anyway, I must have missed something.

I'll double-check the Makefile (and MAKE_ENV) and try again, thanks!
Comment 8 Jan Beich freebsd_committer freebsd_triage 2018-08-28 15:24:02 UTC
(In reply to Ganael LAPLANCHE from comment #5)
> I presume those differences come from base path still being included for headers and libraries.

No. comment 0 is strictly a Clang 7 issue, specific to C++ code. The affected file builds fine with clang++60 from devel/llvm60 on clang700-import branch. GCC hides malformed ordered comparison issues behind -Wextra but, unfortunately, even GCC 8.2.0 doesn't report this case.

libc++ issues are usually more ambiguous but easy to bisect. When object files are built (before linking) only libc++ headers are used, so checking out libc++ trunk, passing -nostdinc++ -isystem/path/to/libcxx/include and jumping a hundred or more commits back is enough to start bisecting then come up with a fix.

> Are you aware of an easy way to reproduce the build problem on 10.4 or 11.2 ?

No, devel/llvm70 was supposed to be the easiest. I'm trying to figure out why the exact same clang++70 command line builds fine for you but not for me.

Slightly more complicated would be to temporarily boot -CURRENT kernel with COMPAT_FREEBSD11 (like in GENERIC). As long as you don't install world/userland you shouldn't bump into ino64 and other ABI issues. poudriere actually relies on backward compatibility to run jails for older releases.
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-09-01 20:22:27 UTC
A commit references this bug:

Author: martymac
Date: Sat Sep  1 20:22:08 UTC 2018
New revision: 478723
URL: https://svnweb.freebsd.org/changeset/ports/478723

Log:
  Fix build with Clang7

  PR:		230502
  Submitted by:	jbeich

Changes:
  head/games/flightgear/files/patch-clang7-src-AIModel-AIFlightPlanCreatePushBack.cxx
  head/games/flightgear/files/patch-clang7-stack_scope.diff
Comment 10 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-09-01 20:24:48 UTC
Hi Jan,

I have finally rebooted on a -CURRENT kernel with COMPAT_FREEBSD11 and have been able to reproduce the build problem :)

I've just committed a fix that I'll submit upstream soon.

Thanks a lot for your help and feedback.

Best regards,

Ganael.
Comment 11 Ganael LAPLANCHE freebsd_committer freebsd_triage 2018-09-01 20:36:28 UTC
Merge request submitted upstream:
https://sourceforge.net/p/flightgear/flightgear/merge-requests/141/