Bug 271928 - lang/ghc: 'make configure' fails with bad --target argument if lang/gcc is installed.
Summary: lang/ghc: 'make configure' fails with bad --target argument if lang/gcc is in...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-haskell (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-09 22:39 UTC by John Hein
Modified: 2023-07-06 18:56 UTC (History)
5 users (show)

See Also:


Attachments
[patch] explicitly use base cc (clang) - v0 (572 bytes, patch)
2023-06-19 16:16 UTC, John Hein
jcfyecrayz: maintainer-approval? (haskell)
Details | Diff
[patch] explicitly use base cc (clang) - v1 (832 bytes, patch)
2023-06-19 16:21 UTC, John Hein
jcfyecrayz: maintainer-approval? (haskell)
Details | Diff
Patch CXX as well (840 bytes, patch)
2023-06-23 10:41 UTC, Mark Evenson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2023-06-09 22:39:52 UTC
'make -C lang/ghc configure' fails if lang/gcc is installed (not just lang/gcc12):

error: gcc: error: unrecognized command-line option '--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd'

This has been happening since the update to 9.4.5 in late May.  However, I had built 9.2.7 BEFORE the switch to Hadrian.  I have not tried building the 9.2.7 port after the switch to Hadrian.

This is on stable-12/amd64.

I'll attach the build log.
Comment 1 Gleb Popov freebsd_committer freebsd_triage 2023-06-10 08:47:15 UTC
I reproduced the issue, but didn't find an easy fix. Unfortunately, I'm drowned in other work, so will not be able to look at that.

You might want try reporting this upstream, as the problem seems to be not in our Ports machinery.
Comment 2 John Hein 2023-06-19 14:56:09 UTC
Adding 'CC=cc' to the configure command in pre-configure seems to do the job.

I did not have to add CC=cc to the later configure (in pre-install) to get the build to succeed.  The pre-install configure DOES still detect gcc ("checking for gcc... gcc"), but I don't know if that will affect anything at run time.  It couldn't hurt to add CC=cc to that configure command as well - I just don't know yet if that is necessary.

I will also sign up to upstream gitlab, and try to report this.
Comment 3 John Hein 2023-06-19 16:16:57 UTC
Created attachment 242878 [details]
[patch] explicitly use base cc (clang) - v0

During pre-configure, explicitly specify base CC=cc - cc is clang now in all supported major versions of FreeBSD (even powerpc these days I think, but I have not confirmed that).

This works around whatever bootstrap issue is going on with gcc (possibly FreeBSD specific, but not known at this time).

With this patch, poudriere now builds lang/ghc if lang/gcc is installed (tested on 12-amd64/stable).
Comment 4 John Hein 2023-06-19 16:21:51 UTC
Created attachment 242879 [details]
[patch] explicitly use base cc (clang) - v1

v1: Same as v0 (specify CC=cc for pre-configure with default BOOT=off), but add CC=cc for the configure called during pre-install as well.

This version is not needed to fix the build problem.  One may consider selecting this version at least for consistency.  I did not do any extensive run-time testing with either version yet.
Comment 5 Mark Evenson 2023-06-23 10:41:00 UTC
Created attachment 242950 [details]
Patch CXX as well
Comment 6 Mark Evenson 2023-06-23 10:43:21 UTC
I had to patch the `pre-install` target's configure with the CXX compiler in order to get this build, otherwise I ran into problems finding libstdc++, otherwise:

[…]
configure:7672: $CC is not gcc; assuming it's a reasonably new C compiler                                                                    
configure:7678: checking whether CC supports -no-pie                                                                                         
configure:7688: result: no                                                                                                                   
configure:7694: checking for extra options to pass gcc when compiling via C                                                                  
configure:7708: result:                                                                                                                      
configure:7716: checking Setting up CFLAGS, LDFLAGS, IGNORE_LINKER_LD_FLAGS and CPPFLAGS                                                     
configure:7810: result: done                                                                                                                 
configure:7815: checking Setting up CONF_CC_OPTS_STAGE0, CONF_GCC_LINKER_OPTS_STAGE0, CONF_LD_LINKER_OPTS_STAGE0 and CONF_CPP_OPTS_STAGE0    
configure:7909: result: done                                                                                                                 
configure:7914: checking Setting up CONF_CC_OPTS_STAGE1, CONF_GCC_LINKER_OPTS_STAGE1, CONF_LD_LINKER_OPTS_STAGE1 and CONF_CPP_OPTS_STAGE1    
configure:8008: result: done                                                                                                                 
configure:8014: checking Setting up CONF_CC_OPTS_STAGE2, CONF_GCC_LINKER_OPTS_STAGE2, CONF_LD_LINKER_OPTS_STAGE2 and CONF_CPP_OPTS_STAGE2    
configure:8108: result: done                                                                                                                 
configure:8220: checking C++ standard library flavour                                                                                        
configure:8233: result: libstdc++                                                                                                            
configure:2: checking for linkage against 'stdc++'                                                                                           
configure:15: result: failed                                                                                                                 
configure:2: checking for linkage against 'stdc++ supc++'                                                                                    
configure:15: result: failed                                                                                                                 
configure:8279: error: Failed to find C++ standard library  
[…]
Comment 7 Mark Evenson 2023-06-23 10:44:43 UTC
(In reply to Mark Evenson from comment #6)

err the `pre-install` target.  The compilation wrt. the invoking ports Makefile itself succeeds.
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-06-24 15:04:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=57bf75dc7fbd09e9cacfe6f077876b66bca618de

commit 57bf75dc7fbd09e9cacfe6f077876b66bca618de
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2023-06-24 14:17:13 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2023-06-24 15:03:11 +0000

    lang/ghc: Pass CC and CXX to Hadrian to fix build in lang/gcc presence.

    PR:             271928
    Reported by:    John Hein <jcfyecrayz@liamekaens.com>, Mark Evenson <evenson.not.org@gmail.com>

 lang/ghc/Makefile | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Comment 9 Gleb Popov freebsd_committer freebsd_triage 2023-06-24 15:10:23 UTC
Thanks both of you, pushed in.
Comment 10 John Hein 2023-07-06 18:55:16 UTC
(In reply to Gleb Popov from comment #9)
Gleb and other haskell-aware people,

This might be a separate bug / question, but it's loosely related to this bug...

When one builds ghc in poudriere, llvm12 is not installed (since it is not a dependency).  But there is a configure problem (a couple times during 'make configure' and once during 'make stage') looking for llc12 and opt12.  Both of those are explicitly specified in configure args (in lang/ghc/Makefile) when BOOT=off.

What is the impact on ghc (build, run, or testing) when missing llc and opt tools?

===========
 .
 .
./configure: llc12: not found
no
configure: We only support llvm 10 to 15 (no version found).
./configure: opt12: not found
no
configure: We only support llvm 10 to 15 (no version found).
 .
 .
===========
Comment 11 Gleb Popov freebsd_committer freebsd_triage 2023-07-06 18:56:29 UTC
LLVM is only required on aarch64. It is perfectly OK that it can't find it on i386 or amd64.