In stan-dev/cmdstanr#1286 I'm experimenting with CmdStanR building
the model methods it loads into R against RcppParallel's oneTBB when that package is installed
(so rstan/rstanarm/brms and cmdstanr can share a process), which means setting TBB_INC and
TBB_LIB on Windows.
While working on that Claude and I ran into this issue.
When TBB_LIB is set, make/compiler_flags adds -Wl,--disable-new-dtags
to LDFLAGS_TBB on every OS except macOS:
# MacOS ld does not support --disable-new-dtags
ifneq ($(OS),Darwin)
LDFLAGS_TBB_DTAGS ?= -Wl,--disable-new-dtags
endif
According to Claude:
--disable-new-dtags controls DT_RPATH versus DT_RUNPATH in ELF
binaries. PE linkers don't know it, so on Windows every link fails. With
Rtools 4.5 (x86_64, binutils ld):
ld.exe: unrecognized option '--disable-new-dtags'
ld.exe: use the --help option for usage information
collect2.exe: error: ld returned 1 exit status
and with Rtools 4.5 for ARM64 (clang 19, lld):
lld: error: unknown argument: --disable-new-dtags
clang-19: error: linker command failed with exit code 1
The flag only matters alongside -rpath, and the block right below already
skips -rpath on Windows, so the same condition should apply to both:
ifneq ($(OS),Darwin)
ifneq ($(OS),Windows_NT)
LDFLAGS_TBB_DTAGS ?= -Wl,--disable-new-dtags
endif
endif
The workaround we're using for now (in the PR I linked to above):
pass LDFLAGS_TBB_DTAGS= on the make command line (or set it in make/local).
Current Version
v5.4.0 (CmdStan 2.40.0)
In stan-dev/cmdstanr#1286 I'm experimenting with CmdStanR building
the model methods it loads into R against RcppParallel's oneTBB when that package is installed
(so rstan/rstanarm/brms and cmdstanr can share a process), which means setting
TBB_INCandTBB_LIBon Windows.While working on that Claude and I ran into this issue.
When
TBB_LIBis set,make/compiler_flagsadds-Wl,--disable-new-dtagsto
LDFLAGS_TBBon every OS except macOS:According to Claude:
The workaround we're using for now (in the PR I linked to above):
pass
LDFLAGS_TBB_DTAGS=on the make command line (or set it inmake/local).Current Version
v5.4.0 (CmdStan 2.40.0)