[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-bugs
Subject:    library/2928:
From:       rob () pickering ! org
Date:       2002-09-23 13:32:43
[Download RAW message or body]

> Number:         2928
> Category:       library
> Synopsis:       
> Confidential:   yes
> Severity:       serious
> Priority:       medium
> Responsible:    bugs
> State:          open
> Quarter:        
> Keywords:       
> Date-Required:
> Class:          sw-bug
> Submitter-Id:   net
> Arrival-Date:   Thu Nov 07 13:14:04 MST 2002
> Closed-Date:
> Last-Modified:
> Originator:     Rob Pickering
> Release:        -current, was in 3.1 too as far as I recall, maybe even 3.0
> Organization:
> Environment:
        
        System      : OpenBSD 3.2
        Architecture: OpenBSD.i386
        Machine     : i386
> Description:
	

"make build" has been failing for me for some time (since at least OPENBSD_3_1) when \
I do a  clean build with DESTDIR set to get a release tree. I finally got annoyed \
about this enough to try and work out why.

It fails when linking ld.so in /usr/src/gnu/usr/bin/ld due to a bug in bsd.prog.mk
which compiles in {DESTDIR}/usr/lib/crt0.o, to avoid using the system C startup \
files.

The link of the ld.so binary doesn't want C startup files, and uses -nostartfiles \
flag at link time. This is fine for a normal link, but bsd.prog.mk overrides this \
when DESTDIR is set and it gets them anyway, resulting in link errors

> How-To-Repeat:
CVS checkout
setenv DESTDIR /var/tmp/foo
mkdir -p $DESTDIR
make build
> Fix:
	
Patch for bsd.prog.mk below omits ${DESTDIR}/usr/lib/crt0.o etc if original LDFLAGS \
had -nostartfiles also added -nostartfiles flag to new linker line if doing an \
ordinary DESTDIR build as I think this is more correct.

===================================================================
RCS file: /cvs/src/share/mk/bsd.prog.mk,v
retrieving revision 1.33
diff -C3 -r1.33 bsd.prog.mk
*** bsd.prog.mk 2002/07/25 18:19:06     1.33
--- bsd.prog.mk 2002/09/23 13:01:13
***************
*** 111,120 ****
  .endif
  
  .if defined(OBJS) && !empty(OBJS)
  .if defined(DESTDIR)
  
  ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
!       ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib \
${LIBCRT0} ${CRTBEGIN} ${OBJS} ${LDADD} -lgcc - lc -lgcc ${CRTEND}
  
  .else
  
--- 111,128 ----
  .endif
  
  .if defined(OBJS) && !empty(OBJS)
+ 
+ .if  !empty(LDFLAGS:M-nostartfiles)
+ 
+ ${PROG}: ${OBJS} ${LIBC} ${DPADD}
+       ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
+ 
+ .else
+ 
  .if defined(DESTDIR)
  
  ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
!       ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostartfiles -nostdlib \
-L${DESTDIR}/usr/lib ${LIBCRT0} ${CRTBEGIN} ${OBJS} ${ LDADD} -lgcc -lc -lgcc \
${CRTEND}  
  .else
  
***************
*** 122,127 ****
--- 130,136 ----
        ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
  
  .endif        # defined(DESTDIR)
+ .endif  # !empty(${LDFLAGS:M-nostartfiles})
  .endif        # defined(OBJS) && !empty(OBJS)
  
  .if   !defined(MAN)


> Release-Note:
> Audit-Trail:
> Unformatted:
 rob@pickering.org
  Rob Pickering
 No
 /usr/src/gnu/usr.bin/ld compilation failes at ld.so link when $DESTDIR set in make \
build  non-critical
 medium
 library
 sw-bug
 -current (was in 3.1 too as far as I recall)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic