maxoodf / word2vec

word2vec++ is a Distributed Representations of Words (word2vec) library and tools implementation, written in C++11 from the scratch
Apache License 2.0
131 stars 24 forks source link

compilation #9

Closed jwijffels closed 4 years ago

jwijffels commented 4 years ago

Hello @maxoodf I'm trying to make sure the R wrapper is ready for CRAN. That includes running it and testing it on many platforms. One of these is Solaris. Unfortunately building the package fails on Solaris due to the following compilation errors Do you know a possible solution to this?

/opt/developerstudio12.6/bin/CC -std=c++11 -library=stdcpp,CrunG3  -I"/opt/R/R-4.0.0/lib/R/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I./word2vec/include -I./word2vec/lib -I'/export/home/XCxYEwn/R/Rcpp/include' -I'/export/home/XCxYEwn/R/RcppProgress/include' -I/opt/csw/include   -KPIC  -O -xlibmil -xtarget=generic -xcache=generic -nofstore  -c word2vec/lib/huffmanTree.cpp -o word2vec/lib/huffmanTree.o
CC: Warning: Option -pthread passed to ld, if ld is invoked, ignored otherwise
/opt/developerstudio12.6/bin/CC -std=c++11 -library=stdcpp,CrunG3  -I"/opt/R/R-4.0.0/lib/R/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I./word2vec/include -I./word2vec/lib -I'/export/home/XCxYEwn/R/Rcpp/include' -I'/export/home/XCxYEwn/R/RcppProgress/include' -I/opt/csw/include   -KPIC  -O -xlibmil -xtarget=generic -xcache=generic -nofstore  -c word2vec/lib/mapper.cpp -o word2vec/lib/mapper.o
CC: Warning: Option -pthread passed to ld, if ld is invoked, ignored otherwise
"./word2vec/include/mapper.hpp", line 74: Warning: Function w2v::fileMapper_t::~fileMapper_t() can throw only the exceptions thrown by the function w2v::mapper_t::~mapper_t() it overrides.
"./word2vec/include/mapper.hpp", line 74: Warning: Function w2v::fileMapper_t::~fileMapper_t() can throw only the exceptions thrown by the function w2v::mapper_t::~mapper_t() it overrides.
"word2vec/lib/mapper.cpp", line 71: Error: Formal argument 1 of type char* in call to munmap(char*, unsigned) is being passed void*.
1 Error(s) and 2 Warning(s) detected.
maxoodf commented 4 years ago

Hello @jwijffels OMG, are there any Solaris users in the world?

It looks like you need to do something like this (mapper.cpp, line 71):

if defined(OS_SOLARIS)

    munmap(m_data.rwData, static_cast<size_t>(m_size));

else

    munmap(reinterpret_cast<void *>(m_data.rwData), static_cast<size_t>(m_size));

endif

jwijffels commented 4 years ago

Hello again. Thanks for the quick reply. Really appreciate it. I had a project last year working on Oracle Solaris. I really started appreciating at that time all the efforts R's CRAN maintainers have been putting in even making sure all R packages on CRAN work on Solaris :)

Note: had to change (#if defined(sun) || defined(__sun)) to the following to make it work when testing the R wrapper on https://builder.r-hub.io/advanced

#if defined(sun) || defined(__sun)
        munmap(m_data.rwData, static_cast<size_t>(m_size));
#else
        munmap(reinterpret_cast<void *>(m_data.rwData), static_cast<size_t>(m_size));
#endif

Also included #include <stdexcept> in trainer.hpp, trainThread.hpp, word2vec.hpp wordReader.hpp and vocabulary.hpp to fix installation on Debian as shown in the below installation trace

g++-10  -std=gnu++11 -I"/home/hornik/tmp/R-d-gcc-10/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I./word2vec/include -I./word2vec/lib -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/Rcpp/include' -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/RcppProgress/include' -I/usr/local/include -DUSE_TYPE_CHECKING_STRICT -D_FORTIFY_SOURCE=2  -fpic  -g -O2 -Wall -pedantic -mtune=native  -c word2vec/lib/huffmanTree.cpp -o word2vec/lib/huffmanTree.o
g++-10  -std=gnu++11 -I"/home/hornik/tmp/R-d-gcc-10/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I./word2vec/include -I./word2vec/lib -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/Rcpp/include' -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/RcppProgress/include' -I/usr/local/include -DUSE_TYPE_CHECKING_STRICT -D_FORTIFY_SOURCE=2  -fpic  -g -O2 -Wall -pedantic -mtune=native  -c word2vec/lib/mapper.cpp -o word2vec/lib/mapper.o
g++-10  -std=gnu++11 -I"/home/hornik/tmp/R-d-gcc-10/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I./word2vec/include -I./word2vec/lib -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/Rcpp/include' -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/RcppProgress/include' -I/usr/local/include -DUSE_TYPE_CHECKING_STRICT -D_FORTIFY_SOURCE=2  -fpic  -g -O2 -Wall -pedantic -mtune=native  -c word2vec/lib/nsDistribution.cpp -o word2vec/lib/nsDistribution.o
g++-10  -std=gnu++11 -I"/home/hornik/tmp/R-d-gcc-10/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I./word2vec/include -I./word2vec/lib -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/Rcpp/include' -I'/home/hornik/lib/R/Library/4.1/x86_64-linux-gnu/RcppProgress/include' -I/usr/local/include -DUSE_TYPE_CHECKING_STRICT -D_FORTIFY_SOURCE=2  -fpic  -g -O2 -Wall -pedantic -mtune=native  -c word2vec/lib/trainer.cpp -o word2vec/lib/trainer.o
In file included from word2vec/lib/trainer.hpp:16,
                 from word2vec/lib/trainer.cpp:9:
./word2vec/include/word2vec.hpp: In member function ‘w2v::vector_t& w2v::vector_t::operator+=(const w2v::vector_t&)’:
./word2vec/include/word2vec.hpp:70:32: error: ‘runtime_error’ is not a member of ‘std’
   70 |                     throw std::runtime_error("word2vec: can not create vector");
      |                                ^~~~~~~~~~~~~
./word2vec/include/word2vec.hpp: In member function ‘w2v::vector_t& w2v::vector_t::operator-=(const w2v::vector_t&)’:
./word2vec/include/word2vec.hpp:94:32: error: ‘runtime_error’ is not a member of ‘std’
   94 |                     throw std::runtime_error("word2vec: can not create vector");
      |                                ^~~~~~~~~~~~~
In file included from word2vec/lib/trainer.hpp:17,
                 from word2vec/lib/trainer.cpp:9:
./word2vec/include/wordReader.hpp: In constructor ‘w2v::wordReader_t<dataMapper_t>::wordReader_t(const dataMapper_t&, std::string, std::string, off_t, off_t, uint16_t)’:
./word2vec/include/wordReader.hpp:59:28: error: ‘range_error’ is not a member of ‘std’
   59 |                 throw std::range_error("wordReader: bounds are out of the file size");
      |                            ^~~~~~~~~~~
./word2vec/include/wordReader.hpp:62:28: error: ‘range_error’ is not a member of ‘std’
   62 |                 throw std::range_error("wordReader: offset is out of the bounds");
      |                            ^~~~~~~~~~~
word2vec/lib/trainer.cpp: In constructor ‘w2v::trainer_t::trainer_t(const std::shared_ptr<w2v::trainSettings_t>&, const std::shared_ptr<w2v::vocabulary_t>&, const std::shared_ptr<w2v::fileMapper_t>&, std::function<void(float, float)>)’:
word2vec/lib/trainer.cpp:19:24: error: ‘runtime_error’ is not a member of ‘std’
   19 |             throw std::runtime_error("train settings are not initialized");
      |                        ^~~~~~~~~~~~~
word2vec/lib/trainer.cpp:24:24: error: ‘runtime_error’ is not a member of ‘std’
   24 |             throw std::runtime_error("vocabulary object is not initialized");
      |                        ^~~~~~~~~~~~~
word2vec/lib/trainer.cpp:29:24: error: ‘runtime_error’ is not a member of ‘std’
   29 |             throw std::runtime_error("file mapper object is not initialized");
      |                        ^~~~~~~~~~~~~
make: *** [/home/hornik/tmp/R-d-gcc-10/etc/Makeconf:171: word2vec/lib/trainer.o] Error 1

I'll push to CRAN today. Let me leave this issue open. I'm expecting to see still some issues when testing with address sanitisers and rchk. Will report here if I have more information.

Hope that you will soon be able to add other compilers in the README section indicating it works.

maxoodf commented 4 years ago

Hello, thanks for the issue. I've committed updates, try to build it on your systems.

jwijffels commented 4 years ago

Thanks! I already made these changes in the R package repository and pushed the package to CRAN using the web form. It is now in their incoming system at ftp://cran.r-project.org/incoming/newbies/ That means someone will look to it within the next 10 days, if ok, it will be put at CRAN and checks will occur on the default CRAN systems (mac os, windows using mingw and gcc, solaris, debian clang / gcc, fedora clang gcc, and with address sanitizers and rchk https://cran.r-project.org/web/checks/check_flavors.html#r-release-windows-ix86_x86_64). That will take another 5-10 days. After which I can report with feedback of possible issues on these build systems.

jwijffels commented 4 years ago

Hello again. R package word2vec was published on CRAN last week: https://CRAN.R-project.org/package=word2vec And building fine on all platforms as indicated at https://cran.r-project.org/web/checks/check_results_word2vec.html that means that it runs on all the platforms indicated at https://cran.r-project.org/web/checks/check_flavors.html#r-devel-linux-x86_64-debian-clang including Solaris 10 using Oracle Developer Studio 12.6 compiler (changes listed above were incorporated to make this wor) No warnings neither with UBSAN/rchk/no-long-double. 🎉

Really great library! Thanks again for providing!