Skip to content

Commit

Permalink
native: fix C++ for FreeBSD
Browse files Browse the repository at this point in the history
Cross-compiling C++ for 32-bit on a 64-bit FreeBSD is not as easy as
installing the respective lib via package management as it is in most
Linux distributions. This configures the build system to honor the
`libstdcpp` feature for 64-bit FreeBSD systems.
  • Loading branch information
miri64 committed Jul 28, 2020
1 parent ecab75b commit 5befda3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions boards/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ ifeq ($(OS_ARCH),x86_64)
endif
ifeq ($(OS),FreeBSD)
ifeq ($(OS_ARCH),amd64)
ifeq ($(DISABLE_LIBSTDCPP),1)
LINKFLAGS += -nodefaultlibs -lgcc_s -lc -lc++ -lm -lpthread
endif
LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
endif
LINKFLAGS += -L $(BINDIR)
Expand Down
12 changes: 12 additions & 0 deletions cpu/native/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
ifeq (FreeBSD,$(OS))
ifeq ($(OS_ARCH),amd64)
DISABLE_LIBSTDCPP ?= 1
endif
ifeq ($(DISABLE_LIBSTDCPP),1)
# static C++ constructors need guards for thread safe initialization
ifneq (,$(filter cpp,$(FEATURES_USED)))
USEMODULE += cxx_ctor_guards
endif
endif
endif

ifneq (,$(filter periph_spi,$(USEMODULE)))
USEMODULE += periph_spidev_linux
endif
Expand Down
4 changes: 0 additions & 4 deletions cpu/native/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ifeq (FreeBSD,$(OS))
DISABLE_LIBSTDCPP ?= 1
endif

FEATURES_PROVIDED += arch_32bit
FEATURES_PROVIDED += arch_native
FEATURES_PROVIDED += cpp
Expand Down

0 comments on commit 5befda3

Please sign in to comment.