`help` 安装期间交叉编译失败:"installing Rd objects failed"

Cross-compilation fails during `help` installation: "installing Rd objects failed"

help 步骤

期间安装自加载库

我在交叉编译时遇到了问题 the R package xml2 on the Conda Forge infrastructure (r-xml2-feedstock)。为 R 执行的 Conda Forge *nix 构建:

R CMD INSTALL --no-test-load --build .

其中 --no-test-load 标志(通常)有助于避免交叉编译的任何问题。动态库的构建,包括链接到目标本机 libxml2,工作正常。但是,包安装在 help 步骤中失败:

* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
** using staged installation
Found INCLUDE_DIR and/or LIB_DIR!
Using PKG_CFLAGS=-I$PREFIX/include/libxml2 
Using PKG_LIBS=-L$PREFIX/lib -lxml2
** libs
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c connection.cpp -o connection.o
arm64-apple-darwin20.0.0-clang -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c init.c -o init.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_doc.cpp -o xml2_doc.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_init.cpp -o xml2_init.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_namespace.cpp -o xml2_namespace.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_node.cpp -o xml2_node.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_output.cpp -o xml2_output.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_schema.cpp -o xml2_schema.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_url.cpp -o xml2_url.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"$BUILD_PREFIX/lib/R/include" -DNDEBUG -I../inst/include -I$PREFIX/include/libxml2  -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -D_FORTIFY_SOURCE=2 -isystem $PREFIX/include -mmacosx-version-min=11.0 -I$PREFIX/include   -fPIC  -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1648746613541/work=/usr/local/src/conda/r-base-4.0.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix  -c xml2_xpath.cpp -o xml2_xpath.o
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L$PREFIX/lib/R/lib -Wl,-dead_strip_dylibs -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -o xml2.dylib connection.o init.o xml2_doc.o xml2_init.o xml2_namespace.o xml2_node.o xml2_output.o xml2_schema.o xml2_url.o xml2_xpath.o -L$PREFIX/lib -lxml2 -L$PREFIX/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
ld: warning: -pie being ignored. It is only used when linking a main executable
installing to /Users/runner/miniforge3/conda-bld/r-xml2_1649126088207/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/R/library/00LOCK-work/00new/xml2/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
Error :  unable to load shared object '/Users/runner/miniforge3/conda-bld/r-xml2_1649126088207/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/R/library/00LOCK-work/00new/xml2/libs/xml2.dylib':
  dlopen(/Users/runner/miniforge3/conda-bld/r-xml2_1649126088207/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/R/library/00LOCK-work/00new/xml2/libs/xml2.dylib, 6): no suitable image found.  Did find:
    /Users/runner/miniforge3/conda-bld/r-xml2_1649126088207/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/R/library/00LOCK-work/00new/xml2/libs/
ERROR: installing Rd objects failed for package ‘xml2’

显然,这失败了,因为 .dylib 不是为主机架构编译的,所以我们不希望它是可加载的。问题是:为什么 help 安装步骤试图加载共享库?以及如何避免这种情况?


我试过的

我已经确认确实只是 help 这一步触发了这个自加载。添加 --no-help 标志后,包构建工作正常。然而,这并不理想 - 最好向所有平台提供帮助手册。

尝试仅排除帮助的特定部分并没有避免自加载错误,即每个 --no-docs--no-html 标志仍然失败。

想法

我怀疑 .Rd 文件中的某些内容(示例?)正在触发 R 尝试加载库。但是,我没有遇到其他使用 Roxygen2 生成的 .Rd 文件作为帮助文档的 R 包的问题。例如,nloptr (package, feedstock) 交叉编译成功。任何关于寻找什么的见解都将不胜感激。


其他详细信息

有些包需要在构建文档时自行导入。 在xml2的情况下,xml选项是从R包加载的 然后注入到文档中。看 https://github.com/r-lib/xml2/blob/ab2078976c9ab57116c7c9175632e7d19d45273f/man/read_xml.Rd#L58

要解决此问题,您必须编译包两次。 一种用于跨架构(Apple Silicon),另一种用于 本机架构(英特尔)并使用本机包 假设生成的文档是 两种架构都一样。可能有一个例子或 conda-forge 中的两个就是这样做的。