Bug 258811

Summary: print/texinfo: respect CC
Product: Ports & Packages Reporter: Evgeniy Khramtsov <evgeniy>
Component: Individual Port(s)Assignee: Po-Chuan Hsieh <sunpoet>
Status: New ---    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (sunpoet)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
v1 (use "git am") none

Description Evgeniy Khramtsov 2021-09-30 16:47:13 UTC
Created attachment 228290 [details]
v1 (use "git am")

print/texinfo uses both CC values by default:

1. For itself, taken from $CC: https://git.savannah.gnu.org/cgit/texinfo.git/tree/configure.ac?h=texinfo-6.8#n194

2. For Perl extension (XS) modules, taken from Perl, unless PERL_EXT_CC is passed:
https://git.savannah.gnu.org/cgit/texinfo.git/tree/configure.ac?h=texinfo-6.8#n55
https://git.savannah.gnu.org/cgit/texinfo.git/tree/tp/Texinfo/XS/configure.ac?h=texinfo-6.8#n77

If one wants to build a compiler (e.g. devel/llvm13) from ports while not having base compiler (cc) (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257622#c2),
and using Perl built using older compiler which no longer exists (or, while having no base cc when using devel/llvm12 and Perl bootstrapped from pkg.FreeBSD.org), then a mismatch will happen, e.g.:

1:
[...]
checking whether the compiler supports GNU C... yes
checking whether /usr/local/llvm13/bin/clang accepts -g... yes
checking for /usr/local/llvm13/bin/clang option to enable C11 features... none needed
checking whether /usr/local/llvm13/bin/clang understands -c and -o together... yes
checking whether the compiler is clang... yes
[...]

2:
[...]
checking for perl... (cached) /usr/local/bin/perl
checking Perl configuration value cc... /usr/local/llvm12/bin/clang
checking Perl configuration value ccflags... -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DUSE_THREAD_SAFE_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include
checking Perl configuration value cccdlflags... -DPIC -fPIC
checking Perl configuration value optimize... -O2 -pipe -O3 -mtune=skylake -mbranches-within-32B-boundaries -fstack-protector-all -fPIE -fPIC -fno-strict-aliasing
checking Perl configuration value ccdlflags...  -Wl,-R/usr/local/lib/perl5/5.32/mach/CORE
checking Perl configuration value libperl... libperl.so.5.32.1
checking Perl configuration value archlibexp... /usr/local/lib/perl5/5.32/mach
checking Perl configuration value privlibexp... /usr/local/lib/perl5/5.32
checking for gcc... /usr/local/llvm12/bin/clang
checking whether the C compiler works... no
configure: error: in `/wrkdirs/usr/ports/print/texinfo/work/texinfo-6.8/tp/Texinfo/XS':
configure: error: C compiler cannot create executables
See `config.log' for more details
configure: error: ./configure failed for tp/Texinfo/XS
configure: building Perl extension (XS) modules will be disabled
[...]

Respect CC using PERL_EXT_CC environment variable to avoid chicken and egg problem.

Sorry for not leaving a short reproducer, I'll get back to submitting a reproducer later after finishing some of my other tasks. I leave this PR here
so the community can find this.