Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation clang error #107

Open
JackStat opened this issue Jul 24, 2016 · 6 comments
Open

Installation clang error #107

JackStat opened this issue Jul 24, 2016 · 6 comments

Comments

@JackStat
Copy link
Contributor

I am unable to install the current master branch because of a clang error

The downloaded binary packages are in
    /var/folders/0x/p_3gmzmj7990ymlmtn0d5j580000gn/T//RtmpStAaCt/downloaded_packages
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ  \
  --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/0x/p_3gmzmj7990ymlmtn0d5j580000gn/T/RtmpStAaCt/devtools6c036871f8b7/gbm-developers-gbm-7b0e3ce'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library'  \
  --install-tests 

* installing *source* package ‘gbm’ ...
** libs
clang-omp++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"  -fopenmp -fPIC  -Wall -mtune=core2 -g -O2  -c adaboost.cpp -o adaboost.o
Assertion failed: (CXXThisValue && "no 'this' value for this function"), function LoadCXXThis, file /tmp/clang-omp20150923-62433-20jwzc/llvm-2015-04-01/tools/clang/lib/CodeGen/CodeGenFunction.h, line 1782.
0  clang-3.5                0x0000000105c2043f llvm::sys::PrintStackTrace(__sFILE*) + 40
1  clang-3.5                0x0000000105c2080c SignalHandler(int) + 227
2  libsystem_platform.dylib 0x00007fff98bb4eaa _sigtramp + 26
3  clang-3.5                0x0000000107212710 guard variable for isAllowedInitiallyIDChar(unsigned int, clang::LangOptions const&)::C99DisallowedInitialIDChars + 77768
4  clang-3.5                0x0000000105c20691 abort + 22
5  clang-3.5                0x0000000105c2067b abort + 0
6  clang-3.5                0x0000000105ffc76e clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 4286
7  clang-3.5                0x0000000106001b0b (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 787
8  clang-3.5                0x0000000105ff68ba clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 102
9  clang-3.5                0x0000000105fe69df clang::CodeGen::CodeGenFunction::EmitCXXMemberCallExpr(clang::CXXMemberCallExpr const*, clang::CodeGen::ReturnValueSlot) + 745
10 clang-3.5                0x0000000105fde7e0 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) + 230
11 clang-3.5                0x0000000106000317 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) + 75
12 clang-3.5                0x0000000105ff68ba clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 102
13 clang-3.5                0x000000010605c807 clang::CodeGen::CodeGenFunction::EmitOMPDirectiveWithLoop(clang::OpenMPDirectiveKind, clang::OpenMPDirectiveKind, clang::OMPExecutableDirective const&) + 1405
14 clang-3.5                0x000000010605a2a0 clang::CodeGen::CodeGenFunction::EmitOMPDirectiveWithParallelMicrotask(clang::OpenMPDirectiveKind, llvm::ArrayRef<clang::OpenMPDirectiveKind>, clang::OMPExecutableDirective const&) + 2510
15 clang-3.5                0x000000010605ee18 clang::CodeGen::CodeGenFunction::EmitOMPParallelForDirective(clang::OMPParallelForDirective const&) + 40
16 clang-3.5                0x0000000106053060 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 72
17 clang-3.5                0x000000010607fd93 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&, clang::Stmt const*) + 95
18 clang-3.5                0x0000000106080332 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1170
19 clang-3.5                0x000000010608a2d4 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 1322
20 clang-3.5                0x0000000106088055 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 505
21 clang-3.5                0x00000001060cc192 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 80
22 clang-3.5                0x000000010607c224 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 132
23 clang-3.5                0x00000001062cd9c1 clang::ParseAST(clang::Sema&, bool, bool) + 316
24 clang-3.5                0x0000000105dac1c9 clang::FrontendAction::Execute() + 67
25 clang-3.5                0x0000000105d8a0de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 528
26 clang-3.5                0x0000000105dd52db clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3995
27 clang-3.5                0x0000000105212ce9 cc1_main(char const**, char const**, char const*, void*) + 1059
28 clang-3.5                0x00000001052122c0 main + 7805
29 libdyld.dylib            0x00007fff91b6c5ad start + 1
Stack dump:
0.  Program arguments: /usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/clang-3.5 -cc1 -fopenmp -omp-main-file-path adaboost.cpp -triple x86_64-apple-macosx10.11.0 -emit-obj -disable-free -main-file-name adaboost.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -gdwarf-2 -dwarf-column-info -coverage-file /private/var/folders/0x/p_3gmzmj7990ymlmtn0d5j580000gn/T/RtmpStAaCt/devtools6c036871f8b7/gbm-developers-gbm-7b0e3ce/src/adaboost.o -resource-dir /usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/../lib/clang/3.5.0 -D NDEBUG -I /Library/Frameworks/R.framework/Resources/include -I /usr/local/include -I /usr/local/include/freetype2 -I /opt/X11/include -I /Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include -stdlib=libc++ -O2 -Wall -fdeprecated-macro -fdebug-compilation-dir /private/var/folders/0x/p_3gmzmj7990ymlmtn0d5j580000gn/T/RtmpStAaCt/devtools6c036871f8b7/gbm-developers-gbm-7b0e3ce/src -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o adaboost.o -x c++ adaboost.cpp 
1.  adaboost.cpp:42:1: current parser token 'double'
2.  adaboost.cpp:30:17: LLVM IR generation of declaration 'CAdaBoost::ComputeWorkingResponse'
3.  adaboost.cpp:30:17: Generating code for declaration 'CAdaBoost::ComputeWorkingResponse'
clang-3.5: error: unable to execute command: Illegal instruction: 4
clang-3.5: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.5.0 
Target: x86_64-apple-darwin15.3.0
Thread model: posix
clang-3.5: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-3.5: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.5: note: diagnostic msg: /var/folders/0x/p_3gmzmj7990ymlmtn0d5j580000gn/T/adaboost-bd29ef.cpp
clang-3.5: note: diagnostic msg: /var/folders/0x/p_3gmzmj7990ymlmtn0d5j580000gn/T/adaboost-bd29ef.sh
clang-3.5: note: diagnostic msg: 

********************
make: *** [adaboost.o] Error 254
ERROR: compilation failed for package ‘gbm’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/gbm’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/gbm’
Error: Command failed (1)
@pdmetcalfe
Copy link
Member

Ooh, we've broken clang.

Anyone with a Mac want to solve this (or buy me one)? 😃

@patr1ckm
Copy link

patr1ckm commented Oct 18, 2016

I can confirm this. I have a mac, but not sure how to fix.

@pdmetcalfe
Copy link
Member

Oh. Super. Thanks!

It builds on the travis OS X environment, if that helps at all?

@patr1ckm
Copy link

It looks like the error has changed, I now get the following:

* installing *source* package ‘gbm’ ...
** libs
clang-omp++ -I/Library/Frameworks/R.framework/Resources/include     -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"  -fopenmp -fPIC  -Wall -mtune=core2 -O3    -c adaboost.cpp -o adaboost.o
In file included from adaboost.cpp:12:
In file included from ./adaboost.h:18:
In file included from ./distribution.h:24:
In file included from ./dataset.h:21:
In file included from ./datadistparams.h:19:
In file included from ./gbm_exception.h:4:
In file included from /usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/../include/c++/v1/string:435:
/usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/../include/c++/v1/iosfwd:90:10: fatal error: 'wchar.h' file not found
#include <wchar.h>  // for mbstate_t
         ^
1 error generated.
make: *** [adaboost.o] Error 1
ERROR: compilation failed for package ‘gbm’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/gbm’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/gbm’
Error: Command failed (1)

@patr1ckm
Copy link

patr1ckm commented Dec 16, 2016

I was able to compile the new gbm under OSX 10.12.1 using g++/gcc-6.

Here are the steps:

  1. Install homebrew
  2. brew install homebrew/versions/gcc6 (this takes 45+ minutes)
  3. brew install clang-omp (I actually don't think this matters since I'm compiling with g++-6 instead of clang)
  4. xcode-select --install (In case you just updated OSX)
  5. The contents of my ~/.R/Makevars is
CC=gcc-6
CXX=g++-6
CXX1X = g++-6
SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp
  1. Install from github

devtools::install_github("gbm-developers/gbm")

The compile commands look like:

g++-6 -I/Library/Frameworks/R.framework/Resources/include     -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"  -fopenmp -fPIC  -Wall -mtune=core2 -O3    -c tweedie.cpp -o tweedie.o

And there are a lot of warnings/deprecations. Here are a sample of them:

node.h:107:8: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   std::auto_ptr<CNode> left_node_ptr_;
        ^~~~~~~~
In file included from /usr/local/Cellar/gcc/6.2.0/include/c++/6.2.0/bits/locale_conv.h:41:0,
                 from /usr/local/Cellar/gcc/6.2.0/include/c++/6.2.0/locale:43,
                 from /usr/local/Cellar/gcc/6.2.0/include/c++/6.2.0/iomanip:43,
                 from /Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include/RcppCommon.h:52,
                 from /Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include/Rcpp.h:27,
                 from datadistparams.h:22,
                 from dataset.h:21,
                 from node.h:26,
                 from varsplitter.h:15,
                 from varsplitter.cpp:12:
/usr/local/Cellar/gcc/6.2.0/include/c++/6.2.0/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;

/var/folders/w5/869dx88d64v2409q78xqhsw00000gp/T//ccXGLXHj.s:3193:11: warning: section "__const_coal" is deprecated
        .section __DATA,__const_coal,coalesced
                 ^      ~~~~~~~~~~~~
/var/folders/w5/869dx88d64v2409q78xqhsw00000gp/T//ccXGLXHj.s:3193:11: note: change section name to "__const"
        .section __DATA,__const_coal,coalesced
                 ^      ~~~~~~~~~~~~
/var/folders/w5/869dx88d64v2409q78xqhsw00000gp/T//ccXGLXHj.s:563:11: warning: section "__textcoal_nt" is deprecated
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                 ^      ~~~~~~~~~~~~~
/var/folders/w5/869dx88d64v2409q78xqhsw00000gp/T//ccXGLXHj.s:563:11: note: change section name to "__text"
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                 ^      ~~~~~~~~~~~~~
/var/folders/w5/869dx88d64v2409q78xqhsw00000gp/T//cceCcXN4.s:3059:11: warning: section "__datacoal_nt" is deprecated
        .section __DATA,__datacoal_nt,coalesced

Here are some benchmarks

set.seed(104)
n <- 10000
p <- 500
x <- matrix(rnorm(n*p), n, p)
b <- rep(.5, ncol(x))
y <- x %*% b

library(microbenchmark)
microbenchmark(gbm::gbm(y~., data=data.frame(y, x), distribution="Gaussian", 
                           n.trees=100, par.details = gbmParallel(num_threads=8)),
               gbm::gbm(y~., data=data.frame(y, x), distribution="Gaussian", 
                           n.trees=100, par.details = gbmParallel(num_threads=1)), 
               times=5)
Unit: seconds
                                                                                                                                expr
 gbm::gbm(y ~ ., data = data.frame(y, x), distribution = "Gaussian",      n.trees = 100, par.details = gbmParallel(num_threads = 8))
 gbm::gbm(y ~ ., data = data.frame(y, x), distribution = "Gaussian",      n.trees = 100, par.details = gbmParallel(num_threads = 1))
      min        lq      mean    median        uq       max neval cld
  6.93019  7.052409  7.225445  7.205979  7.401769  7.536879     5  a 
 15.36158 15.467243 15.649213 15.672217 15.869813 15.875209     5   b

@patr1ckm
Copy link

@pdmetcalfe Update: It should work on MacOS or OS X out of the box without any of the above steps, even without XCode.

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

No branches or pull requests

3 participants