conda-forge / perl-feedstock

A conda-smithy repository for perl.
BSD 3-Clause "New" or "Revised" License
3 stars 32 forks source link

Perl package does not work well with c-compiler #59

Closed croth1 closed 9 months ago

croth1 commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

I think it's currently difficult to install packages into the perl interpreter because the package keeps references to the sysroot of the build environment:

on my mac I get: grep sysroot lib/perl5/5.32/core_perl/Config_heavy.pl

cccdlflags='-fPIC --sysroot=/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk'
config_arg24='-Dsysroot=/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk'
config_args='-de -Dprefix=/Users/christian/miniconda3/envs/test2 -Dvendorprefix=/Users/christian/miniconda3/envs/test2 -Dscriptdir=/Users/christian/miniconda3/envs/test2/bin -Dsitescript=/Users/christian/miniconda3/envs/test2/bin -Dvendorscript=/Users/christian/miniconda3/envs/test2/bin -Duserelocatableinc -Duseshrplib -Dinc_version_list=none -Dprivlib=.../../lib/perl5/core_perl -Dsitelib=.../../lib/perl5/site_perl -Dvendorlib=.../../lib/perl5/vendor_perl -Darchlib=.../../lib/perl5/5.32/core_perl -Dsitearch=.../../lib/perl5/5.32/site_perl -Dvendorarch=.../../lib/perl5/5.32/vendor_perl -Dinstallusrbinperl=n -Dusethreads -Dcccdlflags=-fPIC -Dldflags=-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/christian/miniconda3/envs/test2/lib -L/Users/christian/miniconda3/envs/test2/lib  -Ddefault_inc_excludes_dot=n -Dccflags=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/christian/miniconda3/envs/test2/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/perl_1645063215412/work=/usr/local/src/conda/perl-5.32.1 -fdebug-prefix-map=/Users/christian/miniconda3/envs/test2=/usr/local/src/conda-prefix -D_DARWIN_FEATURE_CLOCK_GETTIME=0 -fno-common -DPERL_DARWIN -no-cpp-precomp -Werror=partial-availability -D_DARWIN_FEATURE_CLOCK_GETTIME=0 -fno-strict-aliasing -pipe -fstack-protector-strong -DPERL_USE_SAFE_PUTENV  -D_FORTIFY_SOURCE=2 -isystem /Users/christian/miniconda3/envs/test2/include -mmacosx-version-min=10.9 -Dcc=x86_64-apple-darwin13.4.0-clang -Dar=x86_64-apple-darwin13.4.0-ar -Dsysroot=/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -Dmyhostname=conda -Dmydomain=.conda -Dperladmin=conda -Dcf_by=conda -Dcf_email=conda -Dsysman=/Users/christian/miniconda3/envs/test2/man/man1 -Dman1dir=.../../man/man1 -Dman3dir=.../../man/man3'
lddlflags='-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/christian/miniconda3/envs/test2/lib -L/Users/christian/miniconda3/envs/test2/lib  -mmacosx-version-min=10.9 -bundle -undefined dynamic_lookup --sysroot=/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -fstack-protector-strong'
sysroot='/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk'

Perl-generated Makefiles that require a c-compiler will have build-env compiler and linker flags and thus would fail:

x86_64-apple-darwin13.4.0-clang  -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/christian/miniconda3/envs/test2/lib -L/Users/christian/miniconda3/envs/test2/lib  -mmacosx-version-min=10.9 -bundle -undefined dynamic_lookup --sysroot=/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -fstack-protector-strong  Simple.o  -o blib/arch/auto/Date/Simple/Simple.bundle  \
          \

ld: library not found for -lSystem
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Installed packages

# packages in environment at /Users/christian/miniconda3/envs/test2:
#
# Name                    Version                   Build  Channel
c-compiler                1.5.2                hbf74d83_0    conda-forge
ca-certificates           2023.5.7             h8857fd0_0    conda-forge
cctools                   973.0.1             h76f1dac_13    conda-forge
cctools_osx-64            973.0.1             hcc6d90d_13    conda-forge
clang                     14.0.6               h694c41f_1    conda-forge
clang-14                  14.0.6          default_hdb78580_1    conda-forge
clang_osx-64              14.0.6               h3113cd8_6    conda-forge
clangxx                   14.0.6          default_hdb78580_1    conda-forge
compiler-rt               14.0.6               h613da45_0    conda-forge
compiler-rt_osx-64        14.0.6               hab78ec2_0    conda-forge
ld64                      609                 hc6ad406_13    conda-forge
ld64_osx-64               609                 hfd63004_13    conda-forge
libclang-cpp14            14.0.6          default_hdb78580_1    conda-forge
libcxx                    16.0.6               hd57cbcb_0    conda-forge
libiconv                  1.17                 hac89ed1_0    conda-forge
libllvm14                 14.0.6               hc8e404f_3    conda-forge
libzlib                   1.2.13               h8a1eda9_5    conda-forge
llvm-openmp               16.0.6               hff08bdf_0    conda-forge
llvm-tools                14.0.6               hc8e404f_3    conda-forge
make                      4.3                  h22f3db7_1    conda-forge
openssl                   3.1.1                h8a1eda9_1    conda-forge
perl                      5.32.1          2_h0d85af4_perl5    conda-forge
pkg-config                0.29.2            ha3d46e9_1008    conda-forge
sigtool                   0.1.3                h88f4db0_0    conda-forge
tapi                      1100.0.11            h9ce4665_0    conda-forge

Environment info

active environment : test2
    active env location : /Users/christian/miniconda3/envs/test2
            shell level : 2
       user config file : /Users/christian/.condarc
 populated config files : /Users/christian/.condarc
          conda version : 23.1.0
    conda-build version : 3.25.0
         python version : 3.9.16.final.0
       virtual packages : __archspec=1=x86_64
                          __osx=13.4.1=0
                          __unix=0=0
       base environment : /Users/christian/miniconda3  (writable)
      conda av data dir : /Users/christian/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/christian/miniconda3/pkgs
                          /Users/christian/.conda/pkgs
       envs directories : /Users/christian/miniconda3/envs
                          /Users/christian/.conda/envs
               platform : osx-64
             user-agent : conda/23.1.0 requests/2.31.0 CPython/3.9.16 Darwin/22.5.0 OSX/13.4.1 solver/libmamba conda-libmamba-solver/22.8.1 libmambapy/1.1.0
                UID:GID : 501:20
             netrc file : None
           offline mode : False
croth1 commented 1 year ago

works like a charm now! Thanks so much @isuruf!

croth1 commented 1 year ago

I might have been too optimistic 😢 - The SDK-setting seems to work nicely, but there still seems to be some errors with the compiler. After updating, I still get for cpan install Params::Validate

Loading internal logger. Log::Log4perl recommended for better logging
Reading '/Users/christian/.cpan/Metadata'
  Database was generated on Wed, 05 Jul 2023 19:41:02 GMT
Running install for module 'Params::Validate'
Checksum for /Users/christian/.cpan/sources/authors/id/D/DR/DROLSKY/Params-Validate-1.31.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring D/DR/DROLSKY/Params-Validate-1.31.tar.gz with Build.PL
ld: unknown option: -Wl,-pie
Warning: ExtUtils::CBuilder not installed or no compiler detected
Proceeding with configuration, but compilation may fail during Build

Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Params-Validate' version '1.31'
  DROLSKY/Params-Validate-1.31.tar.gz
  /Users/christian/miniconda3/envs/test2/bin/perl Build.PL -- OK
Running Build for D/DR/DROLSKY/Params-Validate-1.31.tar.gz
Building Params-Validate
Error: no compiler detected to compile 'lib/Params/Validate/XS.c'.  Aborting
  DROLSKY/Params-Validate-1.31.tar.gz
  ./Build -- NOT OK

The only clue I see is: ld: unknown option: -Wl,-pie - maybe that prevents the compiler from being detected? finding it very hard to debug what's actually happening under the hood 😢

jakirkham commented 1 year ago

Reopening to track this observation with the flags ( https://github.com/conda-forge/perl-feedstock/pull/61#issuecomment-1636692649 )

mbargull commented 9 months ago

The only clue I see is: ld: unknown option: -Wl,-pie - maybe that prevents the compiler from being detected? finding it very hard to debug what's actually happening under the hood 😢

That one came from an issue upstream that we encountered because with c-compiler the LD environment variable is set which in turn triggers undesired behavior we now have patched out with gh-63. @croth1, new builds for perl should be available -- let me know everything works as expected for you with those.