Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: ubuntu without gcc #17043

Closed
p5pRT opened this issue Jun 10, 2019 · 16 comments
Closed

configure: ubuntu without gcc #17043

p5pRT opened this issue Jun 10, 2019 · 16 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jun 10, 2019

Migrated from rt.perl.org#134189 (status was 'pending release')

Searchable as RT134189$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 10, 2019

From @hvds

Created by @hvds

On this new computer with a freshly installed Ubuntu (bionic), I tried
to build blead with clang and threads support, which fell over at the
linking stage missing references such as pthread_get_specific() and
some maths functions.

Tracking back, I found during configure that it had​:
  Checking for optional libraries...
  What libraries to use? [none]

I then found that I hadn't actually installed gcc on this machine, so
the /usr/bin/cc link was also pointing at clang.

After installing gcc (which updated the /usr/bin/cc link), retrying the
clang build successfully found​:
  What libraries to use? [-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc]
.. to create the perl below.

Not sure if the fault here lies with me, perl or clang.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.31.1:

Configured by hv at Mon Jun 10 15:27:56 BST 2019.

Summary of my perl5 (revision 5 version 31 subversion 1) configuration:
  Commit id: 7948efd4698ec5639b8de124f836d9d3064798cb
  Platform:
    osname=linux
    osvers=4.18.0-21-generic
    archname=x86_64-linux-thread-multi
    uname='linux zen2 4.18.0-21-generic #22~18.04.1-ubuntu smp thu may 16 15:07:19 utc 2019 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dcc=clang -Dprefix=/opt/scratch -Doptimize=-g -O3 -Dusethread -Duseithreads -DDEBUGGING -Dusedevel -Uversiononly'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='clang'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-g -O3'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Clang 6.0.0 (tags/RELEASE_600/final)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='clang'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/llvm-6.0/lib/clang/6.0.0/lib /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.27.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.27'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -g -O3 -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.31.1:
    lib
    /opt/scratch/lib/perl5/site_perl/5.31.1/x86_64-linux-thread-multi
    /opt/scratch/lib/perl5/site_perl/5.31.1
    /opt/scratch/lib/perl5/5.31.1/x86_64-linux-thread-multi
    /opt/scratch/lib/perl5/5.31.1
    /opt/scratch/lib/perl5/site_perl/5.28.1
    /opt/scratch/lib/perl5/site_perl


Environment for perl 5.31.1:
    HOME=/home/hv
    LANG=C
    LANGUAGE=en_GB:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/hv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 10, 2019

From @jkeenan

On Mon, 10 Jun 2019 14​:51​:28 GMT, hv wrote​:

This is a bug report for perl from hv@​crypt.org,
generated with the help of perlbug 1.41 running under perl 5.31.1.

-----------------------------------------------------------------
[Please describe your issue here]

On this new computer with a freshly installed Ubuntu (bionic), I tried
to build blead with clang and threads support, which fell over at the
linking stage missing references such as pthread_get_specific() and
some maths functions.

Tracking back, I found during configure that it had​:
Checking for optional libraries...
What libraries to use? [none]

I then found that I hadn't actually installed gcc on this machine, so
the /usr/bin/cc link was also pointing at clang.

After installing gcc (which updated the /usr/bin/cc link), retrying
the
clang build successfully found​:
What libraries to use? [-lpthread -lnsl -ldl -lm -lcrypt -lutil
-lc]
.. to create the perl below.

Not sure if the fault here lies with me, perl or clang.

This is puzzling. I've been running Ubuntu 18.04.02 LTS for most of a year now. I don't recall having to specifically install gcc. However, I was upgrading the OS on a machine from 16.04. Still, if anything I would suspect you'd have to manually install clang rather than gcc.

[snip]

osvers=4\.18\.0\-21\-generic
archname=x86\_64\-linux\-thread\-multi
uname='linux zen2 4\.18\.0\-21\-generic \#22~18\.04\.1\-ubuntu smp thu may

16 15​:07​:19 utc 2019 x86_64 x86_64 x86_64 gnulinux '

What's also odd is that my Linux kernel is only at the 4.15 level -- notwithstanding the fact that I diligently apply all Software Updates.

$ uname -a
Linux zareason 4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14​:27​:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 10, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 10, 2019

From @hvds

On Mon, 10 Jun 2019 08​:52​:48 -0700, jkeenan wrote​:

This is puzzling. I've been running Ubuntu 18.04.02 LTS for most of a
year now. I don't recall having to specifically install gcc.
However, I was upgrading the OS on a machine from 16.04. Still, if
anything I would suspect you'd have to manually install clang rather
than gcc.

I _did_ manually (apt-)install clang; I had also assumed I'd get gcc for free.

Hugo

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 10, 2019

From @ilmari

"Hugo van der Sanden via RT" <perlbug-followup@​perl.org> writes​:

On Mon, 10 Jun 2019 08​:52​:48 -0700, jkeenan wrote​:

This is puzzling. I've been running Ubuntu 18.04.02 LTS for most of a
year now. I don't recall having to specifically install gcc.
However, I was upgrading the OS on a machine from 16.04. Still, if
anything I would suspect you'd have to manually install clang rather
than gcc.

I _did_ manually (apt-)install clang; I had also assumed I'd get gcc for free.

Development tools are not installed by default, but the
'build-essential' package, which is an implicit build-dependency of
every source package, does depend on gcc.

I've installed a fresh bionic VM and installed just git, clang, and
make, and I can reproduce the problem. It boils down to hints/linux.sh
hard-coding gcc to get the multi-arch library paths for the 'plibpth'
variable. Clang does support the -print-search-dirs option, and
changing the hints file to use cc instead of gcc does work, but we'd
have to only do that if cc is clang. As far as I can tell there's no
Configure variable for this, but Configure has a comment that ccname=gcc
for clang, so something like this might be okay, or explicitly checking
for /usr/bin/clang before falling back to $cc.

Inline Patch
diff --git a/hints/linux.sh b/hints/linux.sh
index a985a8ee1b..059e929997 100644
--- a/hints/linux.sh
+++ b/hints/linux.sh
@@ -165,6 +165,8 @@ esac
 # plibpth to bypass this check.
 if [ -x /usr/bin/gcc ] ; then
     gcc=/usr/bin/gcc
+elif [ "$ccname" = "gcc" ]; then
+    gcc="$cc"
 else
     gcc=gcc
 fi

- ilmari
-- 
- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least.               - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article.                      - Calle Dybedahl
@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 11, 2019

From @hvds

On Mon, 10 Jun 2019 14​:06​:38 -0700, ilmari wrote​:

As far as I can tell there's no
Configure variable for this, but Configure has a comment that
ccname=gcc for clang

Sadly that doesn't appear to be the case here​: after removing gcc{,-7} again to test, $ccname is empty when I try that here. The concept works though​: using instead
+elif [ X"$cc" = Xclang ] ; then
+ gcc=$cc
does give me a successful build.

I'm sure there are better ways to do this​: we should at least allow for both 'clang' and '/usr/bin/clang'. I'd also be tempted to test this before '-x /usr/bin/gcc', on the assumption that if the invoker asked for clang we should try to use it.

Hugo

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 13, 2019

From @tonycoz

On Tue, 11 Jun 2019 08​:41​:37 -0700, hv wrote​:

On Mon, 10 Jun 2019 14​:06​:38 -0700, ilmari wrote​:

As far as I can tell there's no
Configure variable for this, but Configure has a comment that
ccname=gcc for clang

Sadly that doesn't appear to be the case here​: after removing gcc{,-7}
again to test, $ccname is empty when I try that here. The concept
works though​: using instead
+elif [ X"$cc" = Xclang ] ; then
+ gcc=$cc
does give me a successful build.

I'm sure there are better ways to do this​: we should at least allow
for both 'clang' and '/usr/bin/clang'. I'd also be tempted to test
this before '-x /usr/bin/gcc', on the assumption that if the invoker
asked for clang we should try to use it.

clang might not be called clang.

For example, I installed clang and no gcc on a clean Ubuntu and /usr/bin/cc was an alias for clang, so a default Configure used "cc".

The attached tries to detect if $cc is clang or if clang is available in PATH (and works-for-me).

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 13, 2019

From @tonycoz

0001-perl-134189-handle-no-gcc-but-clang-is-available.patch
From f3f4584221b8ae058caed153d2db6aeb74a3992d Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 13 Jun 2019 04:04:35 +0000
Subject: [PATCH] (perl #134189) handle no gcc, but clang is available

You can setup Ubuntu (and presumably other dists) with clang and no
gcc installed, which left plibpth unfilled.
---
 hints/linux.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hints/linux.sh b/hints/linux.sh
index a985a8ee1b..796b5faada 100644
--- a/hints/linux.sh
+++ b/hints/linux.sh
@@ -165,6 +165,11 @@ esac
 # plibpth to bypass this check.
 if [ -x /usr/bin/gcc ] ; then
     gcc=/usr/bin/gcc
+# clang also provides -print-search-dirs
+elif [ ! -z "$cc" ] && $cc --version 2>/dev/null | grep -q '^clang ' ; then
+    gcc=$cc
+elif clang --version 2>/dev/null | grep -q '^clang ' ; then
+    gcc=clang
 else
     gcc=gcc
 fi
-- 
2.20.1

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 13, 2019

From @hvds

On Wed, 12 Jun 2019 21​:10​:30 -0700, tonyc wrote​:

clang might not be called clang.

For example, I installed clang and no gcc on a clean Ubuntu and
/usr/bin/cc was an alias for clang, so a default Configure used "cc".

The attached tries to detect if $cc is clang or if clang is available
in PATH (and works-for-me).

The first stanza looks good to me, but for the second stanza I'm not sure it's safe to invoke some arbitrary program called clang in your path if you haven't requested it.

Hugo

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 13, 2019

From @tonycoz

On Thu, Jun 13, 2019 at 03​:53​:10AM -0700, Hugo van der Sanden via RT wrote​:

On Wed, 12 Jun 2019 21​:10​:30 -0700, tonyc wrote​:

clang might not be called clang.

For example, I installed clang and no gcc on a clean Ubuntu and
/usr/bin/cc was an alias for clang, so a default Configure used "cc".

The attached tries to detect if $cc is clang or if clang is available
in PATH (and works-for-me).

The first stanza looks good to me, but for the second stanza I'm not sure it's safe to invoke some arbitrary program called clang in your path if you haven't requested it.

We do it for gcc.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 13, 2019

From @hvds

On Thu, 13 Jun 2019 04​:02​:29 -0700, tonyc wrote​:

The first stanza looks good to me, but for the second stanza I'm not
sure it's safe to invoke some arbitrary program called clang in your
path if you haven't requested it.

We do it for gcc.

I'd class clang as a relative newcomer, it feels much more likely that someone would have a program of that name in their path that has never heard of clang-the-compiler.

Maybe I'm being overcautious, but it makes me nervous.

Hugo

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 19, 2019

From @tonycoz

On Thu, 13 Jun 2019 04​:26​:48 -0700, hv wrote​:

On Thu, 13 Jun 2019 04​:02​:29 -0700, tonyc wrote​:

The first stanza looks good to me, but for the second stanza I'm
not
sure it's safe to invoke some arbitrary program called clang in
your
path if you haven't requested it.

We do it for gcc.

I'd class clang as a relative newcomer, it feels much more likely that
someone would have a program of that name in their path that has never
heard of clang-the-compiler.

Maybe I'm being overcautious, but it makes me nervous.

Here's a maybe more cautious version.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 19, 2019

From @tonycoz

0001-perl-134189-handle-no-gcc-but-cc-is-clang.patch
From a17c73f3be436df41627eaf400266f9e25c15ab6 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 13 Jun 2019 04:04:35 +0000
Subject: (perl #134189) handle no gcc, but cc is clang

You can setup Ubuntu (and presumably other dists) with clang and no
gcc installed, which left plibpth unfilled.
---
 hints/linux.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hints/linux.sh b/hints/linux.sh
index a985a8ee1b..8cbe7dc463 100644
--- a/hints/linux.sh
+++ b/hints/linux.sh
@@ -165,6 +165,9 @@ esac
 # plibpth to bypass this check.
 if [ -x /usr/bin/gcc ] ; then
     gcc=/usr/bin/gcc
+# clang also provides -print-search-dirs
+elif ${cc:-cc} --version 2>/dev/null | grep -q '^clang ' ; then
+    gcc=${cc:-cc}
 else
     gcc=gcc
 fi
-- 
2.20.1

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 19, 2019

From @hvds

On Tue, 18 Jun 2019 22​:49​:41 -0700, tonyc wrote​:

Here's a maybe more cautious version.

Looks good to me, thanks.

Hugo

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 24, 2019

From @tonycoz

On Wed, 19 Jun 2019 02​:26​:19 -0700, hv wrote​:

On Tue, 18 Jun 2019 22​:49​:41 -0700, tonyc wrote​:

Here's a maybe more cautious version.

Looks good to me, thanks.

Thanks for the feedback, applied as 9918f0b.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 24, 2019

@tonycoz - Status changed from 'open' to 'pending release'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.