btrfs-progs: build: fix PIE build

Patch from Marcus Meissner <meissner@suse.com>. The CFLAGS are passed to
the linker and mix up the compilation and linker flags for PIE support.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2017-08-25 14:26:51 +02:00
parent 1fe20f4c64
commit 5d8b645f6f
1 changed files with 16 additions and 16 deletions

View File

@ -360,25 +360,25 @@ $(lib_links):
btrfs-%.static: btrfs-%.static.o $(static_objects) $(patsubst %.o,%.static.o,$(standalone_deps)) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $@.o $(static_objects) \
$(Q)$(CC) -o $@ $@.o $(static_objects) \
$(patsubst %.o, %.static.o, $($(subst -,_,$(subst .static,,$@)-objects))) \
$(static_libbtrfs_objects) $(STATIC_LDFLAGS) \
$($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS)
btrfs-%: btrfs-%.o $(objects) $(standalone_deps) $(libs_static)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o \
$(Q)$(CC) -o $@ $(objects) $@.o \
$($(subst -,_,$@-objects)) \
$(libs_static) \
$(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
btrfs: btrfs.o $(objects) $(cmds_objects) $(libs_static)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)
btrfs.static: btrfs.static.o $(static_objects) $(static_cmds_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) $(STATIC_LIBS_COMP)
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) $(STATIC_LIBS_COMP)
# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
btrfsck: btrfs
@ -391,43 +391,43 @@ btrfsck.static: btrfs.static
mkfs.btrfs: $(mkfs_objects) $(objects) $(libs_static)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
mkfs.btrfs.static: $(static_mkfs_objects) $(static_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS)
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS)
btrfstune: btrfstune.o $(objects) $(libs_static)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
btrfstune.static: btrfstune.static.o $(static_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS)
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS)
btrfs-image: image/main.o $(objects) $(libs_static)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)
btrfs-image.static: image/main.static.o $(static_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) $(STATIC_LIBS_COMP)
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) $(STATIC_LIBS_COMP)
btrfs-convert: $(convert_objects) $(objects) $(libs_static)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(btrfs_convert_libs) $(LIBS)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(btrfs_convert_libs) $(LIBS)
btrfs-convert.static: $(static_convert_objects) $(static_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(btrfs_convert_libs) $(STATIC_LIBS)
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(btrfs_convert_libs) $(STATIC_LIBS)
dir-test: dir-test.o $(objects) $(libs)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
quick-test: quick-test.o $(objects) $(libs)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
ioctl-test.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
@echo " [CC] $@"
@ -449,13 +449,13 @@ ioctl-test: ioctl-test.o
ioctl-test-32: ioctl-test-32.o
@echo " [LD32] $@"
$(Q)$(CC) $(CFLAGS) -m32 -o $@ $< $(LDFLAGS)
$(Q)$(CC) -m32 -o $@ $< $(LDFLAGS)
@echo " ?[PAHOLE] $@.pahole"
-$(Q)pahole $@ > $@.pahole
ioctl-test-64: ioctl-test-64.o
@echo " [LD64] $@"
$(Q)$(CC) $(CFLAGS) -m64 -o $@ $< $(LDFLAGS)
$(Q)$(CC) -m64 -o $@ $< $(LDFLAGS)
@echo " ?[PAHOLE] $@.pahole"
-$(Q)pahole $@ > $@.pahole