Skip to content

Commit

Permalink
Only link with -pthread on Unix
Browse files Browse the repository at this point in the history
We don't want this with MinGW.
  • Loading branch information
Ericson2314 committed Jan 11, 2024
1 parent f9e5eb5 commit 423484a
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions mk/libraries.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ else
endif
endif

ifdef HOST_UNIX
THREAD_LDFLAGS = -pthread
else
THREAD_LDFLAGS =
endif

# Build a library with symbolic name $(1). The library is defined by
# various variables prefixed by ‘$(1)_’:
#
Expand Down
2 changes: 1 addition & 1 deletion src/libcmd/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ libcmd_SOURCES := $(wildcard $(d)/*.cc)

libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers

libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) -pthread
libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) $(THREAD_LDFLAGS)

libcmd_LIBS = libstore libutil libexpr libmain libfetchers

Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/lib

libexpr_LIBS = libutil libstore libfetchers

libexpr_LDFLAGS += -lboost_context -pthread
libexpr_LDFLAGS += -lboost_context $(THREAD_LDFLAGS)
ifdef HOST_LINUX
libexpr_LDFLAGS += -ldl
endif
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ libfetchers_SOURCES := $(wildcard $(d)/*.cc)

libfetchers_CXXFLAGS += -I src/libutil -I src/libstore

libfetchers_LDFLAGS += -pthread $(LIBGIT2_LIBS) -larchive
libfetchers_LDFLAGS += $(THREAD_LDFLAGS) $(LIBGIT2_LIBS) -larchive

libfetchers_LIBS = libutil libstore
2 changes: 1 addition & 1 deletion src/libstore/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc $(d)/build/*.cc)

libstore_LIBS = libutil

libstore_LDFLAGS += $(SQLITE3_LIBS) $(LIBCURL_LIBS) -pthread
libstore_LDFLAGS += $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(THREAD_LDFLAGS)
ifdef HOST_LINUX
libstore_LDFLAGS += -ldl
endif
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ libutil_SOURCES := $(wildcard $(d)/*.cc $(d)/signature/*.cc)

libutil_CXXFLAGS += -I src/libutil

libutil_LDFLAGS += -pthread $(LIBCURL_LIBS) $(SODIUM_LIBS) $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(LIBARCHIVE_LIBS) $(BOOST_LDFLAGS) -lboost_context
libutil_LDFLAGS += $(THREAD_LDFLAGS) $(LIBCURL_LIBS) $(SODIUM_LIBS) $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(LIBARCHIVE_LIBS) $(BOOST_LDFLAGS) -lboost_context

$(foreach i, $(wildcard $(d)/args/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix/args, 0644)))
Expand Down
2 changes: 1 addition & 1 deletion src/nix/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ nix_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libexpr

nix_LIBS = libexpr libmain libfetchers libstore libutil libcmd

nix_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS)
nix_LDFLAGS = $(THREAD_LDFLAGS) $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS)

$(foreach name, \
nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test-libstoreconsumer/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ test-libstoreconsumer_CXXFLAGS += -I src/libutil -I src/libstore

test-libstoreconsumer_LIBS = libstore libutil

test-libstoreconsumer_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS)
test-libstoreconsumer_LDFLAGS = $(THREAD_LDFLAGS) $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS)
2 changes: 1 addition & 1 deletion tests/unit/libexpr-support/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ libexpr-test-support_LIBS = \
libstore-test-support libutil-test-support \
libexpr libstore libutil

libexpr-test-support_LDFLAGS := -pthread -lrapidcheck
libexpr-test-support_LDFLAGS := $(THREAD_LDFLAGS) -lrapidcheck
2 changes: 1 addition & 1 deletion tests/unit/libstore-support/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ libstore-test-support_LIBS = \
libutil-test-support \
libstore libutil

libstore-test-support_LDFLAGS := -pthread -lrapidcheck
libstore-test-support_LDFLAGS := $(THREAD_LDFLAGS) -lrapidcheck
2 changes: 1 addition & 1 deletion tests/unit/libutil-support/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ libutil-test-support_CXXFLAGS += $(libutil-tests_EXTRA_INCLUDES)

libutil-test-support_LIBS = libutil

libutil-test-support_LDFLAGS := -pthread -lrapidcheck
libutil-test-support_LDFLAGS := $(THREAD_LDFLAGS) -lrapidcheck

0 comments on commit 423484a

Please sign in to comment.