我正在尝试使用 R Tools >4.0 工具链(来自 MSYS2 终端 x64 BASH shell)从 Windows 10 上的源代码压缩包编译鸭数据库包(来自 CRAN 的 0.3.1)。
编译是必要的,因为我们的防火墙会阻止从 CRAN 下载预构建的二进制文件。
我首先检查了包裹:
R CMD check -l . --no-stop-on-test-error --install-args="--no-test-load" duckdb_0.3.1-1.tar.gz
这--no-test-load
是因为我们有 DLL 白名单,所以我需要先构建 DLL,然后将它们列入白名单,然后才能加载它们。
这产生了预期的结果:可以编译包(对于 i386 和 x64 架构)并安装,但check
尝试加载包时出错:
* using log directory 'P:/tmp/duckdb.Rcheck'
* using R version 4.0.2 (2020-06-22)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* using option '--no-stop-on-test-error'
* checking for file 'duckdb/DESCRIPTION' ... OK
* this is package 'duckdb' version '0.3.1-1'
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking whether package 'duckdb' can be installed ... OK
* checking installed package size ... NOTE
installed size is 32.4Mb
sub-directories of 1Mb or more:
libs 32.1Mb
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* loading checks for arch 'i386'
** checking whether the package can be loaded ... ERROR
Loading this package had a fatal error status code 1
Loading log:
Loading required package: DBI
Error: package or namespace load failed for 'duckdb' in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'P:/tmp/duckdb/libs/i386/duckdb.dll':
LoadLibrary failure: Access is denied.
Execution halted
** DONE
Status: 1 ERROR, 1 NOTE
See
'P:/tmp/duckdb.Rcheck/00check.log'
for details.
安装日志中有一些与比较有符号和无符号值相关的警告,但没有致命的。这是i386
安装日志部分的结尾,在ld
链接 final时显示没有错误duckdb.dll
:
<secret-path>/Rtools40/mingw32/bin/g++ -shared -s -static-libgcc -o duckdb.dll tmp.def rapi.o database.o connection.o statement.o register.o scan.o utils.o altrep.o types.o duckdb/extension/parquet/column_reader.o duckdb/extension/parquet/parquet-extension.o duckdb/extension/parquet/parquet_metadata.o duckdb/extension/parquet/parquet_reader.o duckdb/extension/parquet/parquet_statistics.o duckdb/extension/parquet/parquet_timestamp.o duckdb/extension/parquet/parquet_writer.o duckdb/amalgamation-1.o duckdb/amalgamation-2.o duckdb/amalgamation-3.o duckdb/amalgamation-4.o duckdb/amalgamation-5.o duckdb/amalgamation-6.o duckdb/amalgamation-7.o duckdb/third_party/fmt/format.o duckdb/third_party/hyperloglog/hyperloglog.o duckdb/third_party/hyperloglog/sds.o duckdb/third_party/libpg_query/pg_functions.o duckdb/third_party/libpg_query/postgres_parser.o duckdb/third_party/libpg_query/src_backend_nodes_list.o duckdb/third_party/libpg_query/src_backend_nodes_makefuncs.o duckdb/third_party/libpg_query/src_backend_nodes_value.o duckdb/third_party/libpg_query/src_backend_parser_gram.o duckdb/third_party/libpg_query/src_backend_parser_parser.o duckdb/third_party/libpg_query/src_backend_parser_scan.o duckdb/third_party/libpg_query/src_backend_parser_scansup.o duckdb/third_party/libpg_query/src_common_keywords.o duckdb/third_party/miniz/miniz.o duckdb/third_party/parquet/parquet_constants.o duckdb/third_party/parquet/parquet_types.o duckdb/third_party/re2/re2/bitstate.o duckdb/third_party/re2/re2/compile.o duckdb/third_party/re2/re2/dfa.o duckdb/third_party/re2/re2/filtered_re2.o duckdb/third_party/re2/re2/mimics_pcre.o duckdb/third_party/re2/re2/nfa.o duckdb/third_party/re2/re2/onepass.o duckdb/third_party/re2/re2/parse.o duckdb/third_party/re2/re2/perl_groups.o duckdb/third_party/re2/re2/prefilter.o duckdb/third_party/re2/re2/prefilter_tree.o duckdb/third_party/re2/re2/prog.o duckdb/third_party/re2/re2/re2.o duckdb/third_party/re2/re2/regexp.o duckdb/third_party/re2/re2/set.o duckdb/third_party/re2/re2/simplify.o duckdb/third_party/re2/re2/stringpiece.o duckdb/third_party/re2/re2/tostring.o duckdb/third_party/re2/re2/unicode_casefold.o duckdb/third_party/re2/re2/unicode_groups.o duckdb/third_party/re2/util/rune.o duckdb/third_party/re2/util/strutil.o duckdb/third_party/snappy/snappy-sinksource.o duckdb/third_party/snappy/snappy.o duckdb/third_party/thrift/thrift/protocol/TProtocol.o duckdb/third_party/thrift/thrift/transport/TBufferTransports.o duckdb/third_party/thrift/thrift/transport/TTransportException.o duckdb/third_party/utf8proc/utf8proc.o duckdb/third_party/utf8proc/utf8proc_wrapper.o duckdb/third_party/zstd/common/entropy_common.o duckdb/third_party/zstd/common/error_private.o duckdb/third_party/zstd/common/fse_decompress.o duckdb/third_party/zstd/common/xxhash.o duckdb/third_party/zstd/common/zstd_common.o duckdb/third_party/zstd/compress/fse_compress.o duckdb/third_party/zstd/compress/hist.o duckdb/third_party/zstd/compress/huf_compress.o duckdb/third_party/zstd/compress/zstd_compress.o duckdb/third_party/zstd/compress/zstd_compress_literals.o duckdb/third_party/zstd/compress/zstd_compress_sequences.o duckdb/third_party/zstd/compress/zstd_compress_superblock.o duckdb/third_party/zstd/compress/zstd_double_fast.o duckdb/third_party/zstd/compress/zstd_fast.o duckdb/third_party/zstd/compress/zstd_lazy.o duckdb/third_party/zstd/compress/zstd_ldm.o duckdb/third_party/zstd/compress/zstd_opt.o duckdb/third_party/zstd/decompress/huf_decompress.o duckdb/third_party/zstd/decompress/zstd_ddict.o duckdb/third_party/zstd/decompress/zstd_decompress.o duckdb/third_party/zstd/decompress/zstd_decompress_block.o duckdb/amalgamation-8.o -LC:<secret-path>/R-40~1.2/bin/i386 -lR
There were 50 or more warnings (use warnings() to see the first 50)
installing to P:/tmp/00LOCK-duckdb/00new/duckdb/libs/i386
*** arch - x64
<snip similar log for x64 architecture...>
最后,我在“duckdb”目录中有一个完全编译和安装的包——由于 DLL 白名单,我无法将它加载到我的 R 会话中。到目前为止,一切都很好。
然后我尝试使用R CMD INSTALL --no-test-load -l . duckdb_0.3.1-1.tar.gz
(和变体)安装包。不幸的是,构建失败。日志似乎与它尝试将 .o 文件链接到 .o 文件的点相同duckdb.dll
,此时:
<secret-path>/Rtools40/mingw32/bin/g++ -shared -s -static-libgcc -o duckdb.dll tmp.def rapi.o database.o connection.o statement.o register.o scan.o utils.o altrep.o types.o duckdb/extension/parquet/column_reader.o duckdb/extension/parquet/parquet-extension.o duckdb/extension/parquet/parquet_metadata.o duckdb/extension/parquet/parquet_reader.o duckdb/extension/parquet/parquet_statistics.o duckdb/extension/parquet/parquet_timestamp.o duckdb/extension/parquet/parquet_writer.o duckdb/amalgamation-1.o duckdb/amalgamation-2.o duckdb/amalgamation-3.o duckdb/amalgamation-4.o duckdb/amalgamation-5.o duckdb/amalgamation-6.o duckdb/amalgamation-7.o duckdb/third_party/fmt/format.o duckdb/third_party/hyperloglog/hyperloglog.o duckdb/third_party/hyperloglog/sds.o duckdb/third_party/libpg_query/pg_functions.o duckdb/third_party/libpg_query/postgres_parser.o duckdb/third_party/libpg_query/src_backend_nodes_list.o duckdb/third_party/libpg_query/src_backend_nodes_makefuncs.o duckdb/third_party/libpg_query/src_backend_nodes_value.o duckdb/third_party/libpg_query/src_backend_parser_gram.o duckdb/third_party/libpg_query/src_backend_parser_parser.o duckdb/third_party/libpg_query/src_backend_parser_scan.o duckdb/third_party/libpg_query/src_backend_parser_scansup.o duckdb/third_party/libpg_query/src_common_keywords.o duckdb/third_party/miniz/miniz.o duckdb/third_party/parquet/parquet_constants.o duckdb/third_party/parquet/parquet_types.o duckdb/third_party/re2/re2/bitstate.o duckdb/third_party/re2/re2/compile.o duckdb/third_party/re2/re2/dfa.o duckdb/third_party/re2/re2/filtered_re2.o duckdb/third_party/re2/re2/mimics_pcre.o duckdb/third_party/re2/re2/nfa.o duckdb/third_party/re2/re2/onepass.o duckdb/third_party/re2/re2/parse.o duckdb/third_party/re2/re2/perl_groups.o duckdb/third_party/re2/re2/prefilter.o duckdb/third_party/re2/re2/prefilter_tree.o duckdb/third_party/re2/re2/prog.o duckdb/third_party/re2/re2/re2.o duckdb/third_party/re2/re2/regexp.o duckdb/third_party/re2/re2/set.o duckdb/third_party/re2/re2/simplify.o duckdb/third_party/re2/re2/stringpiece.o duckdb/third_party/re2/re2/tostring.o duckdb/third_party/re2/re2/unicode_casefold.o duckdb/third_party/re2/re2/unicode_groups.o duckdb/third_party/re2/util/rune.o duckdb/third_party/re2/util/strutil.o duckdb/third_party/snappy/snappy-sinksource.o duckdb/third_party/snappy/snappy.o duckdb/third_party/thrift/thrift/protocol/TProtocol.o duckdb/third_party/thrift/thrift/transport/TBufferTransports.o duckdb/third_party/thrift/thrift/transport/TTransportException.o duckdb/third_party/utf8proc/utf8proc.o duckdb/third_party/utf8proc/utf8proc_wrapper.o duckdb/third_party/zstd/common/entropy_common.o duckdb/third_party/zstd/common/error_private.o duckdb/third_party/zstd/common/fse_decompress.o duckdb/third_party/zstd/common/xxhash.o duckdb/third_party/zstd/common/zstd_common.o duckdb/third_party/zstd/compress/fse_compress.o duckdb/third_party/zstd/compress/hist.o duckdb/third_party/zstd/compress/huf_compress.o duckdb/third_party/zstd/compress/zstd_compress.o duckdb/third_party/zstd/compress/zstd_compress_literals.o duckdb/third_party/zstd/compress/zstd_compress_sequences.o duckdb/third_party/zstd/compress/zstd_compress_superblock.o duckdb/third_party/zstd/compress/zstd_double_fast.o duckdb/third_party/zstd/compress/zstd_fast.o duckdb/third_party/zstd/compress/zstd_lazy.o duckdb/third_party/zstd/compress/zstd_ldm.o duckdb/third_party/zstd/compress/zstd_opt.o duckdb/third_party/zstd/decompress/huf_decompress.o duckdb/third_party/zstd/decompress/zstd_ddict.o duckdb/third_party/zstd/decompress/zstd_decompress.o duckdb/third_party/zstd/decompress/zstd_decompress_block.o duckdb/amalgamation-8.o -LC:<secret-path>/R-4.0.2/bin/i386 -lR
<secret-path>\Rtools40\mingw32\i686-w64-mingw32\bin\ld.exe: cannot open output file duckdb.dll: No such file or directory
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'duckdb'
* removing 'P:/tmp/duckdb'
注意我已经混淆了可执行文件的完整路径,但是在没有编译代码的情况下构建和安装包没有问题,所以我知道 R 工具通常在这个环境中工作。check
我已经比较了和运行的安装日志,INSTALL
但我似乎找不到任何看起来很重要的东西。唯一真正的区别是,在check
日志中,使用波浪号的缩短路径似乎被传递给构建实用程序,例如-LC:<secret-path-with-tildes>/R-40~1.2/bin/i386 -lR
传递给ld
的参数,check
而在INSTALL
运行中使用扩展路径。这些路径有点长(大约 110 个字符),我想知道这是否会导致ld
窒息——但没有嵌入空格。我怀疑这是问题所在,但为了完整性而提及它。
R CMD check
通过调用了解确切的参数将非常有帮助,INSTALL
这样我就可以缩小范围。我在“编写 R 扩展”手册或“R 内部”手册的“工具”部分中找不到此文档。我还快速搜索了ld
手册,但没有提到长路径。如果不是很明显,我没有使用编译器的经验(除了在我家里的 Debian 盒子上发生的自动魔法)。我的下一个策略是进行源代码潜水,但我希望尽可能避免这种情况。
可能还值得一提的是,我们的站点包库已添加到我的.Rprofile
(除了 configure 之外什么都不做.libPaths()
),并且我知道check
应该使用 运行--vanilla
,所以我也尝试运行eg R --vanilla CMD INSTALL ...
,但结果相同。我还想知道分阶段安装目录是否可能有所不同,所以我尝试传递--no-staged-install
到INSTALL
,再次得到相同的结果,此时我决定寻求帮助以理解问题而不是继续试用-和错误。