Skip to contentSkip to conversation

PATCH: use CFLAGS when linking always

PATCH Dennis Gilmore 2 participants 4 messages May 5, 2007 – May 6, 2007 Library code

lore
Share & tools
lore
#0 lore raw

for multilib archs default CFLAGS may be inappropriate and reslut in binaries unable to be linked. since e2fsprogs uses gcc for linking I noticed this while building for sparc64. patch has been tested and applied in Aurora SPARC Linux.

Please CC me on responses.

Dennis

configure renamed from configure.BAD +1 -1
@@ -14645,7 +14645,7 @@
 
 if test $cross_compiling = no; then
    BUILD_CFLAGS="$CFLAGS"
-   BUILD_LDFLAGS="$LDFLAGS"
+   BUILD_LDFLAGS="$CFLAGS $LDFLAGS"
 else
    BUILD_CFLAGS=
    BUILD_LDFLAGS=
configure.in renamed from configure.in.BAD +1 -1
@@ -830,7 +830,7 @@
 dnl
 if test $cross_compiling = no; then
    BUILD_CFLAGS="$CFLAGS"
-   BUILD_LDFLAGS="$LDFLAGS"
+   BUILD_LDFLAGS="$CFLAGS $LDFLAGS"
 else
    BUILD_CFLAGS=
    BUILD_LDFLAGS=
lib/Makefile.elf-lib renamed from lib/Makefile.elf-lib.BAD +1 -1
@@ -24,7 +24,7 @@
 
 $(ELF_LIB): $(OBJS)
 	@echo "	GEN_ELF_SOLIB $(ELF_LIB)"
-	@(cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \
+	@(cd elfshared; $(CC) $(CFLAGS) --shared -o $(ELF_LIB) $(LDFLAGS) \
 		-Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
 	@$(MV) elfshared/$(ELF_LIB) .
 	@$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
MCONFIG.in renamed from MCONFIG.in.BAD +1 -1
@@ -40,7 +40,7 @@
 ALL_CFLAGS = $(CPPFLAGS) $(DEFS) $(USE_WFLAGS) $(CFLAGS) $(XTRA_CFLAGS) \
 	$(INTL_FLAGS) $(LINUX_INCLUDE) 
 LDFLAGS = @LDFLAGS@
-ALL_LDFLAGS = $(LDFLAGS)
+ALL_LDFLAGS = $(LDFLAGS) $(CFLAGS)
 BUILD_CFLAGS = @BUILD_CFLAGS@
 BUILD_LDFLAGS = @BUILD_LDFLAGS@
 RM = @RM@
lib/ext2fs/Makefile.in renamed from lib/ext2fs/Makefile.in.BAD +8 -8
@@ -189,17 +189,17 @@
 	@echo "	LD $@"
 	@$(CC) -o tst_badblocks tst_badblocks.o freefs.o \
 		read_bb_file.o write_bb_file.o badblocks.o \
-		inline.o bitops.o gen_bitmap.o $(LIBCOM_ERR)
+		inline.o bitops.o gen_bitmap.o $(ALL_CFLAGS) $(LIBCOM_ERR)
 
 tst_iscan: tst_iscan.o inode.o badblocks.o test_io.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
 	@$(CC) -o tst_iscan tst_iscan.o inode.o badblocks.o test_io.o \
-		$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
+		$(ALL_CFLAGS) $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
 tst_getsize: tst_getsize.o getsize.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
-	@$(CC) -o tst_getsize tst_getsize.o getsize.o $(STATIC_LIBEXT2FS) \
-		$(LIBCOM_ERR)
+	@$(CC) -o tst_getsize tst_getsize.o getsize.o $(ALL_CFLAGS) \
+		$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
 tst_ismounted: $(srcdir)/ismounted.c $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
@@ -207,8 +207,8 @@
 
 tst_byteswap: tst_byteswap.o bitops.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
-	@$(CC) -o tst_byteswap tst_byteswap.o bitops.o $(STATIC_LIBEXT2FS) \
-		$(LIBCOM_ERR)
+	@$(CC) -o tst_byteswap tst_byteswap.o bitops.o $(ALL_CFLAGS) \
+		$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
 tst_bitops: tst_bitops.o inline.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
@@ -218,11 +218,11 @@
 tst_getsectsize: tst_getsectsize.o getsectsize.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
 	@$(CC) -o tst_sectgetsize tst_getsectsize.o getsectsize.o \
-		$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
+		$(ALL_CFLAGS) $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
 tst_types: tst_types.o ext2_types.h 
 	@echo "	LD $@"
-	@$(CC) -o tst_types tst_types.o 
+	@$(CC) -o tst_types tst_types.o $(ALL_CFLAGS) 
 
 mkjournal: mkjournal.c $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
lib/blkid/Makefile.in renamed from lib/blkid/Makefile.in.BAD +2 -2
@@ -114,7 +114,7 @@
 
 tst_types: tst_types.o blkid_types.h 
 	@echo "	LD $@"
-	@$(CC) -o tst_types tst_types.o 
+	@$(CC) -o tst_types tst_types.o $(ALL_CFLAGS)
 
 ../../misc/blkid.o: $(top_srcdir)/misc/blkid.c blkid.h
 	@echo "	CC $@"
@@ -123,7 +123,7 @@
 
 blkid: ../../misc/blkid.o libblkid.a $(DEPLIBUUID)
 	@echo "	LD $@"
-	@$(CC) -o blkid ../../misc/blkid.o libblkid.a $(LIBUUID)
+	@$(CC) -o blkid ../../misc/blkid.o libblkid.a $(LIBUUID) $(ALL_CFLAGS)
 
 test_probe: test_probe.in Makefile
 	@echo "Creating test_probe..."
#1 lore raw
Quoted 4 lines · Dennis Gilmore

for multilib archs default CFLAGS may be inappropriate and reslut in binaries unable to be linked. since e2fsprogs uses gcc for linking I noticed this while building for sparc64. patch has been tested and applied in Aurora SPARC Linux.

What options do you need, and why don't you just specify them via:

configure --with-ldopts="--foo-ld-flag"

- Ted

#2 lore raw
Quoted 11 lines · Theodore Tso
Quoted 4 lines · Dennis Gilmore

for multilib archs default CFLAGS may be inappropriate and reslut in binaries unable to be linked. since e2fsprogs uses gcc for linking I noticed this while building for sparc64. patch has been tested and applied in Aurora SPARC Linux.

What options do you need, and why don't you just specify them via:

configure --with-ldopts="--foo-ld-flag"

- Ted

defaults on sparc64 result in 64 bit objects but gcc trying to create a 32 bit binary. as a result the build blows up horribly. the patch ensures that CFLAGS is used in linking. since gcc is used to link it is needed.

Dennis

#3 lore raw
Quoted 9 lines · Dennis Gilmore
Quoted 8 lines · Theodore Tso
Quoted 4 lines · Dennis Gilmore

for multilib archs default CFLAGS may be inappropriate and reslut in binaries unable to be linked. since e2fsprogs uses gcc for linking I noticed this while building for sparc64. patch has been tested and applied in Aurora SPARC Linux.

What options do you need, and why don't you just specify them via:

Quoted 8 lines
Quoted 3 lines

configure --with-ldopts="--foo-ld-flag"

- Ted

defaults on sparc64 result in 64 bit objects but gcc trying to create a 32 bit binary. as a result the build blows up horribly. the patch ensures that CFLAGS is used in linking. since gcc is used to link it is needed.

What CFLAGS are you passing to configure, exactly? And why can't you also pass them to configure via --with-ldopts?

- Ted