如何在OSX 10.15中使用Clang -Wno-nullability-completeness选项编译整个R源程序包

问题描述 投票:0回答:1

基于OSX 10.15中stackoverflow中的多个发布,我可以通过warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]conftest.cclang -Wno-nullability-completeness -o conftest -g -O2 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include conftest.c中抑制gcc -Wno-nullability-completeness conftest.c。但是如何从源代码编译整个R pacakge呢?我在[R Makevers]中这样添加了-Wno-nullability-completeness

CC=clang -Wno-nullability-completeness
CXX=clang++ -Wno-nullability-completeness
CFLAGS=-Wno-nullability-completeness -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-Wno-nullability-completeness -g -O3 -Wall -pedantic -std=c++11 -mtune=native
LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include

但是没有用。任何建议或指示将不胜感激。

我的系统;

sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.2
BuildVersion:   19C57

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.2.0_2/libexec/gcc/x86_64-apple-darwin19/9.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../configure --build=x86_64-apple-darwin19 --prefix=/usr/local/Cellar/gcc/9.2.0_2 --libdir=/usr/local/Cellar/gcc/9.2.0_2/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0_2' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
Thread model: posix
gcc version 9.2.0 (Homebrew GCC 9.2.0_2)

clang -v
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

brew info R
R: stable 3.6.2 (bottled)
Software environment for statistical computing
https://www.r-project.org/
/usr/local/Cellar/R/3.6.2 (2,123 files, 58.5MB)
  Poured from bottle on 2019-12-14 at 09:37:12
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/r.rb
==> Dependencies
Build: pkg-config ✔
Required: gcc ✔, gettext ✔, jpeg ✔, libpng ✔, openblas ✔, pcre ✔, readline ✔, xz ✔

标志:

CPATH=/usr/local/include
LDFLAGS=-L/usr/local/opt/llvm/lib
CPPFLAGS=-I/usr/local/opt/llvm/include
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

编辑1

[根据Ralf Stubner的建议,我查看了install.package("e1071", keep_outputs=T)生成的安装程序输出;

All my packages loaded Tue Dec 31 16:23:24 2019* installing *source* package ‘e1071’ ...
** package ‘e1071’ successfully unpacked and MD5 sums checked
** using staged installation
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -std=gnu++11 accepts -g... yes
** libs
clang -I"/usr/local/Cellar/r/3.6.2/lib/R/include" -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include  **-fPIC  -g -O2**  -c Rsvm.c -o Rsvm.o
In file included from Rsvm.c:2:
/usr/local/include/stdio.h:67:13: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern FILE *__stdinp ........;

并且我意识到我的Makevars中的CXXFLAG可能根本无法被clang读取。以下是我目前的Makevars;

LLVM_LOC = /usr/local/opt/llvm
CC=clang
CXX=clang++
CXX11=clang++

CFLAGS = -g -O3 -Wall -pipe -pedantic -Wno-nonnull -std=gnu99 -mtune=native
CXXFLAGS = -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native
CXX11FLAGS = -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native

LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include
c++ r macos llvm-clang
1个回答
0
投票

好吧,我知道了。感谢RalfStubner的帮助。我意识到我没有将Makevars放在正确的位置。 Makevars的默认位置应为〜/ .R / Makevars。现在,读取Makevars中的CXXFLAGS并应用-Wno-nonnull。我最新的Makevars如下;

LLVM_LOC = /usr/local/opt/llvm
CC=$(LLVM_LOC)/bin/clang -fopenmp
CXX=$(LLVM_LOC)/bin/clang++ -fopenmp

CC=clang
CXX=clang++
CXX11=clang++

CFLAGS = -g -O3 -Wall -pipe -pedantic -Wno-nonnull -std=gnu99 -mtune=native -pipe
CXXFLAGS = -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native
CXX11FLAGS = -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native

LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include 
© www.soinside.com 2019 - 2024. All rights reserved.