How can I setup LLVM 7 as default C / C++ compiler in Bionic

Hi all, as title, I have a Travis project that kept failing due to this error:

if [ ! -r node -o ! -L node ]; then ln -fs out/Release/node node; fi
-> cd /home/travis/build/slee047/node-packer
-> cp "/tmp/nodec_tests_tmpdir/node-10.16.2-1.6.0/out/Release/node" "/home/travis/build/slee047/node-packer/a.out"
internal/modules/cjs/loader.js:638
    throw err;
    ^
Error: Cannot find module '/__enclose_io_memfs__/bin/coffee'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:835:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Traceback (most recent call last):
tests/coffeescript_1:59:in `<main>': unhandled exception

The log is here:
https://travis-ci.org/slee047/node-packer/jobs/570121416

and the config is here:

https://travis-ci.org/slee047/node-packer/jobs/570121416/config

On top of Bionic (GCC7), I have tested using Xenial (GCC 5) but still fails. Therefore, I would like to try LLVM because it is possible for Mac version (With up to XCode 10 only, XCode 11 will result in early failure due to another separate issue) to be compiled successfully.

I believe the recent build failures are to be related with this bug:

https://github.com/slee047/node-packer/issues/11

1 Like

That depends on your build system. Most build systems in Linux accept the standard way, setting CC and CXX envvars.

In the case of LLVM 7, that’ll be:

addons:
  apt:
    packages:
      - clang-7

env:
  # may need to be under 'global:' or 'matrix:' if 'env:' is on top level,
  # see https://docs.travis-ci.com/user/environment-variables/
  # Or just 'export' them in the script
   - CC=clang-7
     CXX=clang++-7

Though the specific error you gave looks like a problem with your code at first glance: earlier in the log, there’s a warning referencing a #define that suggests that the name of the “module” that’s not found is something that you yourself pass.

1 Like

Thanks, apparently it is using clang but it still fails. I guess it is some other non-Travis related issue that happens only in Linux (BTW, the original author has provided 2 CIs, AppVeyor is used for Windows exclusively and there is no error there). What I am trying to do is to sideload / patch the bundled Node.js with a newer version regularly as it updates into my forked github repo.

https://travis-ci.org/slee047/node-packer/builds/570427117

Imprint