#1876 sdcc won't compile on ubuntu 11.10 AMD64 (with PATCH)

closed-duplicate
assembler (26)
5
2013-05-25
2011-11-16
Mark Whitis
No

sudo tar jxvf /dist/sdcc-src-3.0.0.tar.bz2
sudo ./configure
sudo make all

gcc -pipe -ggdb -g -O2 -Wall -DSDCDB -DNOICE -DINDEXLIB -I. -I. -I./../asxxsrc -I./../../support/Util -I. -I../.. -I./../../support/Util -I. -pipe -ggdb -g -O2 -Wall -lm -o ../../bin/sdasgb obj/gbext.o obj/gbpst.o obj/gbmch.o obj/gbadr.o obj/asdbg.o obj/asdata.o obj/asexpr.o obj/aslex.o obj/aslist.o obj/asmain.o obj/asout.o obj/assubr.o obj/assym.o obj/sdas.o obj/strcmpi.o obj/dbuf.o obj/dbuf_string.o
obj/asmain.o: In function `asmbl':
/usr/local/src/sdcc/sdcc/sdas/asgb/../asxxsrc/asmain.c:891: undefined reference to `log'
/usr/local/src/sdcc/sdcc/sdas/asgb/../asxxsrc/asmain.c:891: undefined reference to `floor'
/usr/local/src/sdcc/sdcc/sdas/asgb/../asxxsrc/asmain.c:892: undefined reference to `exp'
collect2: ld returned 1 exit status
make[1]: *** [../../bin/sdasgb] Error 1
make[1]: Leaving directory `/usr/local/src/sdcc/sdcc/sdas/asgb'
make: *** [sdcc-as] Error 2

ii libc-bin 2.13-20ubuntu5 Embedded GNU C Library: Binaries
ii libc-dev-bin 2.13-20ubuntu5 Embedded GNU C Library: Development binaries
ii libc6 2.13-20ubuntu5 Embedded GNU C Library: Shared libraries
ii libc6:i386 2.13-20ubuntu5 Embedded GNU C Library: Shared libraries
ii libc6-dev 2.13-20ubuntu5 Embedded GNU C Library: Development Libraries and Header Files
ii libc6-i386 2.13-20ubuntu5 Embedded GNU C Library: 32-bit shared libraries for AMD64
ii gcc 4:4.6.1-2ubuntu5 GNU C compiler

This would seem like something wrong with libc, yet the following compiles with -O0 and -lm:

#include <math.h>
#include <stdio.h>
int main(int argc, char **argv)
{
float x,y,z;
x=floor(log(exp(1.0)));
printf("x=%g\n",x);
}

moving -lm to the end of the gcc command allows that particular compilation to succeed. Classic case of link dependency order, which some systems are very picky about.

But make all still falls on its face compiling sdas 8051

/usr/local/src/sdcc/sdcc/sdas/as8051/Makefile.in contains:

$(ASX): $(ASOBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(ASOBJECTS)

Which puts -lm in the wrong place.

The attached patch fixes the problem for 8051 but it will then fail for the same reasons on: sdas/asgb

And fgrep suggests that sdas/as6808 and sdas/asz80 will also have the bug.
This same patch needs to be applied in 4 directories:
sdas/as8051
sdas/asgb
sdas/asz80
sdas/as6808
The same patchfile works in all.
have to run make clean, .configure, and make all again

Initial version of patch added LDLIBFLAGS, handled similarly to LDFLAGS, but It turns out that this won't work as is because the autoconf doesn't define LDLIBFLAGS as it does LDFLAGS. Turns out this should have been in LIBS not LDFLAGS.\ Revised patchfile using LIBS.

Now compiles and installs.

Discussion

  • Mark Whitis

    Mark Whitis - 2011-11-16

    patchfile

     
  • Borut Ražem

    Borut Ražem - 2011-11-17

    Mark, can you please remove -lm from LDFLAGS and see if it still works:

    LDFLAGS = @LDFLAGS@

    Borut

     
  • Borut Ražem

    Borut Ražem - 2011-11-18
    • labels: --> assembler
    • milestone: --> fixed
    • assigned_to: nobody --> borutr
    • status: open --> closed-duplicate
     
  • Borut Ražem

    Borut Ražem - 2011-11-18

    This was already fixed in svn revision #6055.

    P.S.: Before submitting the bug please verify if it was already fixed in the svn HEAD or in the latest snapshot build. This can save some precious time to sdcc developers.

    Borut

     

Log in to post a comment.