Skip to content

Commit 1caac0c

Browse files
committed
Use CC rather than LD for linking
LDFLAGS is really meant to be passed to CC, not LD. The current code fails e.g. with Debian's default LDFLAGS (-Wl,-z,relro). Fix this by switching our Makefile to use CC for linking.
1 parent de504c0 commit 1caac0c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ CFLAGS+=-g -rdynamic
2020
#CFLAGS += -pg
2121
#LDFLAGS += -pg
2222

23-
LDFLAGS+=-shared -g -fPIC -lpthread -lrt -lz -lc
23+
LDFLAGS+=-g -fPIC
24+
LIBS=-lpthread -lrt -lz -lc
2425

2526
.PHONY:
2627

@@ -33,9 +34,9 @@ libs: $(LIBNAME).so.$(LIBVER) $(LIBNAME).a
3334

3435

3536
$(LIBNAME).so.$(LIBVER): $(OBJS)
36-
$(LD) -shared -soname $@ $(LDFLAGS) \
37-
--version-script=librdkafka.lds \
38-
$(OBJS) -o $@
37+
$(CC) -shared $(LDFLAGS) \
38+
-Wl,-soname=$@ -Wl,--version-script=librdkafka.lds \
39+
$(OBJS) -o $@ $(LIBS)
3940

4041
$(LIBNAME).a: $(OBJS)
4142
$(AR) rcs $@ $(OBJS)

0 commit comments

Comments
 (0)