Skip to content

TBB_LIB on Windows adds --disable-new-dtags, which Rtools' linkers reject #3414

Description

@jgabry

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions