bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefined reference to `__alloca'


From: Earnestly
Subject: Re: undefined reference to `__alloca'
Date: Sat, 18 Nov 2017 16:17:38 +0000
User-agent: Mutt/1.9.1 (2017-09-22)

On Thu, Nov 02, 2017 at 11:40:50AM +0000, Earnestly wrote:
> Hi,
>
> For reference my system has the following versions and environs:
>
> * gcc 7.2.0
> * glibc 2.26.9000 (commit 2fac6a6cd5)
> * make 4.2.90 (commit baa57d2) [patched, see below]
>
> * CPPFLAGS -D_FORTIFY_SOURCE=2
> * CFLAGS -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong 
> -fno-plt
> * LDFLAGS -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
>
> For awhile now I've been having an issue when building make from master
> (currently 0c5a9f9) which results in the following error:
>
>     ...
>     gcc -isystem /usr/include/guile/2.2 -pthread -Wall -Wextra -Werror 
> -Wwrite-strings -Wshadow -Wpointer-arith -Wdeclaration-after-statement 
> -Wbad-function-cast -Wformat-security -Wtype-limits 
> -Wunused-but-set-parameter -Wlogical-op -Wignored-qualifiers 
> -Wformat-signedness -Wduplicated-cond -march=x86-64 -mtune=generic -O2 -pipe 
> -fstack-protector-strong -fno-plt -Wl,--export-dynamic 
> -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o make ar.o arscan.o 
> commands.o default.o dir.o expand.o file.o function.o getopt.o getopt1.o 
> guile.o implicit.o job.o load.o loadapi.o main.o misc.o posixos.o output.o 
> read.o remake.o rule.o signame.o strcache.o variable.o version.o vpath.o 
> hash.o remote-stub.o glob/libglob.a -lguile-2.2 -lgc   -ldl
>     glob/libglob.a(glob.o): In function `glob_in_dir':
>     glob.c:(.text+0x2d4): undefined reference to `__alloca'
>     glob.c:(.text+0x450): undefined reference to `__alloca'
>     glob.c:(.text+0x609): undefined reference to `__alloca'
>     glob.c:(.text+0x66a): undefined reference to `__alloca'
>     glob/libglob.a(glob.o): In function `glob':
>     glob.c:(.text+0x985): undefined reference to `__alloca'
>     glob/libglob.a(glob.o):glob.c:(.text+0x103c): more undefined references 
> to `__alloca' follow
>     collect2: error: ld returned 1 exit status
>
> I've worked around this with a quick diff but I'm unsure why this is
> necessary or if it breaks any other platforms so I'm not creating it as
> a patch:
>
>     diff --git a/glob/glob.c b/glob/glob.c
>     index f3911bc..e4d551e 100644
>     --- a/glob/glob.c
>     +++ b/glob/glob.c
>     @@ -208,8 +208,6 @@ my_realloc (p, n)
>      #endif /* __GNU_LIBRARY__ || __DJGPP__ */
>
>
>     -#if !defined __alloca && !defined __GNU_LIBRARY__
>     -
>      # ifdef  __GNUC__
>      #  undef alloca
>      #  define alloca(n)      __builtin_alloca (n)
>     @@ -229,8 +227,6 @@ extern char *alloca ();
>
>      # define __alloca        alloca
>
>     -#endif
>     -
>      #ifndef __GNU_LIBRARY__
>      # define __stat stat
>      # ifdef STAT_MACROS_BROKEN
>
> Thanks

Just to update on this, I have found this patch does work as suspected:

    diff --git a/glob/glob.c b/glob/glob.c
    index f3911bc..8adbde3 100644
    --- a/glob/glob.c
    +++ b/glob/glob.c
    @@ -208,7 +208,7 @@ my_realloc (p, n)
     #endif /* __GNU_LIBRARY__ || __DJGPP__ */


    -#if !defined __alloca && !defined __GNU_LIBRARY__
    +#if !defined __alloca && defined __GNU_LIBRARY__

     # ifdef    __GNUC__
     #  undef alloca

However I am now getting:

    glob.c: In function ‘glob’:
    glob.c:814:11: warning: implicit declaration of function ‘__stat’; did you 
mean ‘__xstat’? [-Wimplicit-function-declaration]
             : __stat (dirname, &st)) == 0
               ^~~~~~
               __xstat

:(



reply via email to

[Prev in Thread] Current Thread [Next in Thread]