Skip to content

RcppParallel 6.1.1: tbbLibraryPath() broken on Windows - looks in build-time RTools not runtime #270

Closed

Description

@andrjohns

The use of RcppParallel::tbbLibraryPath("tbb") on Windows returns nothing when called from the CRAN pre-built binary, and tbbRoot() returns a filepath on a D:/ drive:

utils::packageVersion("RcppParallel")
#> [1] '6.1.1'
RcppParallel::tbbLibraryPath("tbb")
RcppParallel:::tbbRoot()
#> [1] "D:/rtools45/x86_64-w64-mingw32.static.posix/lib"

All works as expected when RcppParallel is built from source:

install.packages("RcppParallel", type = "source")
#> Installing package into 'C:/Users/andrew/AppData/Local/R/win-library/4.6'
#> (as 'lib' is unspecified)
RcppParallel::tbbLibraryPath("tbb")
#> [1] "C:/rtools45/x86_64-w64-mingw32.static.posix/lib/libtbb12.a"
RcppParallel:::tbbRoot()
#> [1] "C:/rtools45/x86_64-w64-mingw32.static.posix/lib"

This appears to be due to RcppParallel looking in the dir specified by the internal TBB_LIB variable set by the configure run at package build time, rather than the location at runtime

Activity

  1. kevinushey commented on Jul 28, 2026

    @kevinushey
    Contributor

    Argh. Thanks for the bug report; I'll take a look.

  2. kevinushey commented on Jul 28, 2026

    @kevinushey
    Contributor

    Beyond this, what actual issue(s) are you seeing with using RcppParallel right now? A more concrete example would be helpful.

  3. andrjohns commented on Jul 28, 2026

    @andrjohns
    ContributorAuthor

    I've got a package that I've updated to link directly to the tbb libraries instead of RcppParallel, and it uses RcppParallel::tbbLibraryPath() to lookup the right location and library name.

    Unfortunately, this results in a build failure on Windows when the library path returns nothing:

     Error in basename(RcppParallel::tbbLibraryPath("tbb")) : 
       a character vector argument expected
     Calls: cat -> basename
     Execution halted
     g++ -std=gnu++20 -shared -s -static-libgcc -o StanEstimators.dll tmp.def StanEstimators.o init.o -LC:/Rtools/x86_64-w64-mingw32.static.posix/lib -l -LC:/rtools45/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools45/x86_64-w64-mingw32.static.posix/lib -LC:/R/bin/x64 -lR
     C:\rtools45\x86_64-w64-mingw32.static.posix\bin/ld.exe: cannot find -l-LC:/rtools45/x86_64-w64-mingw32.static.posix/lib/x64: Invalid argument
    
  4. kevinushey commented on Jul 28, 2026

    @kevinushey
    Contributor

    Thanks; that's exactly the example I needed. One thought, though -- why not use RcppParallelLibs() instead of deriving the TBB library paths + compiler invocation by hand?

    EDIT: But that also appears to be similarly broken ...

  5. andrjohns commented on Jul 28, 2026

    @andrjohns
    ContributorAuthor

    Thanks; that's exactly the example I needed. One thought, though -- why not use RcppParallelLibs() instead of deriving the TBB library paths + compiler invocation by hand?

    EDIT: But that also appears to be similarly broken ...

    That change was spawned from this issue where the recommendation was to link against TBB directly since the symbols weren't exported through RcppParallel anymore - but it looks like that might have changed?

  6. kevinushey commented on Jul 28, 2026

    @kevinushey
    Contributor

    You're right, but now that I've seen the fallout, I think I'm going to revert that and return to just shipping tbb.dll and tbbmalloc.dll, with the correct TBB flags.

  7. kevinushey commented on Jul 30, 2026

    @kevinushey
    Contributor

    Alright -- RcppParallel 6.2.0 is now on CRAN and we again ship separate tbb libraries that you should be able to discover and link to as appropriate.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions