Compile LLVM on Travis-ci - clang

I need to compile a project against LLVM/Clang 3.9.1 built with some particular flags (RTTI and CXX1Y), so in my .travis.yml I firstly download LLVM/Clang 3.9 source, then I build it as I need and finally I install it in /usr/bin.
When (after this phase) I try to run llvm-config --version and clang --version I discover that the version 5.0.0 is considered.
Is there a way to run a build on travis-ci without LLVM/Clang to be installed or a way to set the version 3.9.1 as the default llvm-config and clang executables?

Travis CI can be built without any preinstalled C/C++ compilers (e.g. set language: ruby in your .travis.yml file) but the better/safer way might be to specify your compiler explicitly in your build system. Like Stanislav mentioned in a comment, you could use CMAKE_CXX_COMPILER if you use CMake.

Related

Have rules_cc use latest version of GCC

I am using Bazel to build my project. One of the dependencies is Abseil, which in turn depends on rules_cc.
I notice that when I have multiple versions of GCC installed, rules_cc may be directing Bazel to use an older version of GCC even though I want the newest version of GCC to be used. To get around this, I have been manually editing bazel-project/external/local_config_cc/BUILD to reference the newest version of GCC.
Is there a better or "right" way to do this?
Add that flag to .buildrc (or to your bazel build invocation):
build --action_env=CC=/path/to/your/gcc
you can also set a CXX variable, but at this moment only a CC is used by Bazel
That approach use toolchain automatically generated by Bazel. You can also create your own toolchain, but it is a complicated process.

bazel missing dependency declarations for stddef.h and others Ubuntu 18.04

I am trying to build an existing project using bazel, but get complains of the form
ERROR: .../BUILD:115:1: Couldn't build file xxx.o: undeclared inclusion(s) in rule '#yyy:
this rule is missing dependency declarations for the following files included by zzz.c':
'/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h'
'/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h'
'/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h'
'/usr/lib/gcc/x86_64-linux-gnu/7/include/stdalign.h'
I am just setting up this code base, and I believe that other people can build.
It seems that I should not have to declare system include paths, especially in other people's code. Other people don't seem to have this problem. Did I inadvertently skip a setup step?
bazel version: 0.19.2
gcc version: 7.3.0
clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
OS: Ubuntu 18.04
Is there perhaps a .bazelrc file in which I can specify that system headers do not need to be explicitly declared?
Same problem after upgrade to 18.04.
Fixed by:
Completely clearing bazel cache as in https://stackoverflow.com/a/48524741,
And
Uninstalling bazel and re-installing again from scratch.

In cxfreeze, can I specify the python version I want the executable to use?

Situation:
In my Mac Os 10.8.5 I have available python2.7 and python2.7-32 with latest cx_freeze(-4.3.2).
I need cx_freeze to pick the python2.7-32 version so my executable app can use a 32-bit version of OpenCV.
So far, all attempts to use cx_freeze script suggest that it bundles python2.7(which is 64bit) and the app fails to execute with: "cv2.so: mach-o, but wrong architecture"
(This is the same error you would get if you try to import OpenCV built in 32 bits, with a python interpreter of 64)
Is there a way to "force" cxfreeze to bundle a specific python version installed (in this case python2.7-32) in the executable it produces?
Edit:
I've also tried to build cx-freeze from source in 32-bit using:
python2.7-32 setup.py build;
python2.7-32 setup.py install
No matter what, the app generated is still a 64bit version:
$ python2.7-32 setup.py bdist_dmg
$ file capturebasic
capturebasic: Mach-O 64-bit executable x86_64
$ arch -i386 ./capturebasic
arch: posix_spawnp: ./capturebasic: Bad CPU type in executable
Edit2:
It seems that Mac's cx_freeze you download from sourceforge is only 64-bit:
http://sourceforge.net/projects/cx-freeze/files/4.3.2/
If you want to create 32-bit apps, you need the 32-bit version of cx_freeze.
I'm confirming if there's any way to install the 32bit version in Mac in cx_freeze's mailing list.
I believe you do not have to touch your setup script, but just change the command used to build it. For instance instead of using python setup.py build, you would use the command python2.7-32 setup.py build. You may have to specify the path to the python2.7-32 exe. so something like path\to\python2.7-32.exe setup.py build. Note: I use windows so the example commands I used might be a little different on mac, like instead of .exe it's .app.
Hope this helped.

Building Clang, libstdc++4.6 to libstdc++4.7

I am trying to build Clang following this: http://clang.llvm.org/get_started.html
At step 6 the command ../llvm/configure runs a series of checks and one tells me:
checking whether Clang will select a modern C++ standard library... no
configure: error:
We detected a missing feature in the standard C++ library that was known to be
missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
than 4.7. You will need to update your system and ensure Clang uses the newer
standard library.
If this error is incorrect or you need to force things to work, you may pass
'--disable-compiler-version-checks' to configure to bypass this test.
I don't know how to resolve this and google searches for libstdc++4.7 did not produce anything useful to me or something I understand. How do I go about replacing / upgrading this? I am on a Mac (10.7.5)
I ran into the same problem. The easiest way to build Clang is to use libc++ instead of libstdc++. If you don't have libc++, you can obtain it by installing XCode 4.2 (or newer) or you can build it yourself by following the instructions here: http://libcxx.llvm.org/
After you have libc++ installed, you can use the --enable-libcpp=yes flag with the configure command.
Just this week, the LLVM & Clang project upped the minimal compiler version requirement to gcc 4.7, with its libstdc++. You'll need to install or build a newer gcc.
Here's a blog post I wrote earlier today about building gcc 4.8 on Ubuntu 12.04 and using that to compile trunk LLVM & Clang. Hope this helps!
i have the same error on mac 10.8.5 xcode 5.0
configure option --enable-libcpp resolve my problem
../llvm/configure --enable-cxx11 --enable-optimized --enable-libcpp
For me this happened because I had the old clang and clang++ that I'd previously built from source (the one I was attempting to build to replace) coming first in my PATH. These were too old. Removing those two files so that the build process would use the clang and clang++ that comes with XCode's Command Line Tools and then rebuilding worked fine.

How do install libraries for both Lua5.2 and 5.1 using Luarocks?

I am writing a small Lua project and using Luarocks to install my 3rd-party dependencies. The default Lua version on my machine is 5.2 and up to this point everything is working just fine.
However, today I have stumbled across a problem that is confusing me. I want to run my program on Lua 5.1 and Luajit to see if it would also work on those versions but I am having a hard time getting Luarocks to download the appropriate versions of the dependencies. As a last resort hack, I have tried to tell Lua5.1 to use the 5.2 libraries that Luarocks installed (by setting the LUA_PATH environment variable to the same value as LUA_PATH_5_2) but unfortunately that is not enough: my project depends on LuaFileSystem, a C-based module, so I'm going to need to have separate versions of it installed for 5.1 and 5.2.
What do I have to do to install both the 5.1 and 5.2 versions of my dependencies? Do I need to pass some parameters to theluarocks install command? Do I need to have multiple instances of Luarocks installed on my machine? One thing that confuses me is that the inside the .luarocks folder things are classified under a 5.2 subfolder (~/.luarocks/share/lua/5.2/), suggesting that maybe there could be a way to install things in a sibling 5.1 folder but at the same time there is only one bin folder, suggesting that luarocks is only able to handle one version of Lua at a time...
Based on your reference to ~/.luarocks/share/lua/5.2/, you seem to be running a Unix system (Linux or Mac). You can install the latest version of LuaRocks twice, for both Lua 5.1 and Lua 5.2 like this:
./configure --lua-version=5.1 --versioned-rocks-dir
make build
sudo make install
And then again for 5.2:
./configure --lua-version=5.2 --versioned-rocks-dir
make build
sudo make install
This will get you /usr/local/bin/luarocks-5.1 and /usr/local/bin/luarocks-5.2. If you installed Lua 5.1 and 5.2 in /usr/local/, and each of them will use its own ~/.luarocks/lib/luarocks/rocks-5.x/ entry for the user tree (and /usr/local/lib/luarocks/rocks-5.x for the system tree), and install modules to the right location at /usr/share/lua/5.x/ and ~/.luarocks/share/lua/5.x/ (and likewise for lib) appropriately.
As suggested by moteus, I decided to install a second version of Luarocks for Lua 5.1. But he is using Windows and I am using Linux so here is what I did:
Download the source for the latest version of Luarocks on the Luarocks website
From the source directory, run the ./configure script:
/configure --prefix="${HOME}/.luarocks51" --lua-suffix=5.1
The prefix setting tells Luarocks to put its stuff on the .luarocks51 folder, next to the existing .luarocks folder from my 5.2 install of Luarocks. The lua-suffix parameter tells Luarocks to use Lua 5.1 instead of the default lua version in my machine (5.2). This depends on me having named the interpreter for Lua 5.1 as lua5.1 (Debian installed mine on /usr/bin/lua5.1). Finally, Luarocks managed to automatically detect where the 5.1 headers and libraries are installed (/usr/include/lua5.1/) but if it didn't I guess I could have specified that with the --with-lua-include and --with-lua-lib parameters.
Compile Luarocks with make
Install it with make isntall (no need for Sudo since I'm installing it in a local directory).
Configure my 5.1 environment to use the libraries downloaded by Luarocks. I added the following to my .bashrc:
export PATH=$PATH:~/.luarocks/bin:~/.luarocks51/bin
export LUA_CPATH=";;${HOME}/.luarocks51/lib/lua/5.1/?.so"
export LUA_PATH=";;${HOME}/.luarocks51/share/lua/5.1/?.lua;${HOME}/.luarocks51/share/lua/5.1/?/init.lua"
export LUA_CPATH_5_2=";;${HOME}/.luarocks/lib/lua/5.2/?.so"
export LUA_PATH_5_2=";;${HOME}/.luarocks/share/lua/5.2/?.lua;${HOME}/.luarocks/share/lua/5.2/?/init.lua"
The 5.1 configuration also works for Luajit.
The executable for the 5.1 version of luarocks is named luarocks-5.1:
luarocks-5.1 install lfs
You have to mention both lua version and lua dir in the latest versions:
luarocks --lua-dir=$(brew --prefix)/opt/lua#5.1 --lua-version=5.1 install lua-cassandra
Using homebrew, you can do:
brew install lua51 # Lua 5.1
brew install lua # Lua latest
Luarocks comes with Lua, so you can do:
# Install Lua 5.1 version of any package
luarocks-5.1 install moonscript
# Install Lua latest version of any package
luarocks install moonscript

Resources