Skip to content

Commit

Permalink
Ensure libraries linked are listed after objects using them
Browse files Browse the repository at this point in the history
The Ubuntu toolchain uses -Wl,--as-needed by default, which causes
libraries to be dropped from the final binary if they aren't used.  For
portability, make sure that libraries are always listed on the linker
commandline /after/ the objects that reference them.
.
This also avoids passing -l options to the compiler when compiling .o files.
  • Loading branch information
vorlonofportland authored and jcharaoui committed Sep 10, 2019
1 parent f13d4bb commit 4415066
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ VERSION=1.1.9
CFLAGS+= -O2 -Wall -Wextra -Wshadow -rdynamic\
-D_FILE_OFFSET_BITS=64 -DVERSION=\"$(VERSION)\" \
`pkg-config --cflags-only-I gumbo libcurl fuse`
LDFLAGS+= -pthread -lgumbo -lcurl -lfuse -lcrypto \
`pkg-config --libs-only-L gumbo libcurl fuse`
LIBS = -pthread -lgumbo -lcurl -lfuse -lcrypto
COBJS = main.o network.o fuse_local.o link.o cache.o util.o

prefix ?= /usr/local
Expand All @@ -15,7 +14,7 @@ all: httpdirfs
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $<

httpdirfs: $(COBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

install:
install -m 755 -D httpdirfs \
Expand Down

4 comments on commit 4415066

@jcharaoui
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fangfufu I meant to push this on my fork and submit a pull request... This is a patch submitted by an Ubuntu/Debian developper for httpdirfs-fuse, which was originally posted here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=939361

@fangfufu
Copy link
Owner

@fangfufu fangfufu commented on 4415066 Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcharaoui, I know I sound clueless, but what's the difference between using a pull request and merging directly into the master branch? I suppose a pull request allows a code review?

@jcharaoui
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, a pull request allows for discussion & further modification before a change is accepted (or not) into the master branch.

@fangfufu
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy with this change, I did manage to fix it in 97ecbff, although this one makes things a bit clearer.

Please sign in to comment.