Cevelop / Issues

The official issue tracker for Cevelop.
9 stars 1 forks source link

C++17 issue #57

Closed aacirino closed 6 years ago

aacirino commented 6 years ago

I can't set Cevelop to compile with -std=c++17. If I set the "Other dialect flags" field in the project's C/C++ Build -> settings -> LLVM Clang++ -> Dialect to -std=c++17 Cevelop will report an error as pasted below, after the the compiler invocation:

clang++ -I/usr/local/include -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -std=c++17 -o main.bc ../main.cpp error: invalid value 'c++17' in '-std=c++17'

But if I just paste the compile invocation as built by Cevelop in the terminal I am able to manually compile the file. My system is

macOS 10.11.6 El Capitan Cevelop 1.8.0-201707131430 clang 5.0

PeterSommerlad commented 6 years ago

Hi, while clang 5 supports the flag -std=c++17, Apple's XCode's clang does not. If you have clang 5 installed via homebrew or similar, you might call XCode's clang instead. Please check Cevelop's preferences/C++/Build/Environment and examine the PATH environment variable. If your clang 5 is installed in /usr/local/bin, but PATH contains /usr/bin in the front, Cevelop will call XCode's Clang. Set the PATH environment variable within Cevelop to have the installation location of your Clang 5 in the front, then the option -std=c++17 should work.

Regards Peter.

aacirino commented 6 years ago

Hi Peter, actually it didn't solve the issue. The PATH environment variable wasn't set up in Cevelop and I entered it accordingly to my clang 5.0 installation but the issue remains. In the command line the PATH is correct as can be seen from issuing a simple command: Hackintosh:~ aacirino$ clang++ -v clang version 5.0.0 (tags/RELEASE_500/final) Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin

PeterSommerlad commented 6 years ago

From the Cevelop UI you need to copy the PATH environment variable, even when it is not set directly and then set it to what you need. The settings in your shell are not influencing the settings in an app. Is your setting something like on the attached image? screen shot 2017-11-03 at 13 48 16

I had similar problems in the past and I am sure that is a problem with your mac set up and not a bug in Cevelop.

What happens in your shell when you enter the command which clang++?

tcorbat commented 6 years ago

If Peter's suggestion does not help: Could you try adding the "-v" option to the clang command within Cevelop? You should be able to insert into the miscellaneous options in the build settings, similar as you did for the -std=c++17 flags. It won't compile the files with that option anymore, but it will print the version on the build console. Does it print the same?

aacirino commented 6 years ago

To simplify the setting I only included the path to clang5.0 in Cevelop:

path

The path is the same for the command line: Hackintosh:~ aacirino$ which clang++ /usr/local/opt/llvm/bin/clang++

Using the -v option shows that Cevelop is indeed invoking Apple's clang instead of using the one installed in the above PATH: clang++ -I/usr/local/include -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -v -std=c++17 -o Person.bc ../Person.cpp Apple LLVM version 8.0.0 (clang-800.0.42.1)

aacirino commented 6 years ago

I was able to circumvent the issue by setting the LLVM Clang++ command and linker setting explicitly to /usr/local/opt/llvm/bin/clang++

tcorbat commented 6 years ago

It is possible that Cevelop separately set the environment for the project. There are two locations to set the build environment:

Have you set the PATH variable in the properties?

aacirino commented 6 years ago

Solved, in the project settings -> C/C++ Build -> Environment -> PATH the dir order was wrong. In the global preferences the PATH was correctly set, but not in the project settings. Thanx a lot

tcorbat commented 6 years ago

Great that it works now! I think this might be a candidate for our FAQ.

aacirino commented 6 years ago

As a final note, I've just created a new project. In the global preferences my build environment variable PATH is correctly set and I selected the option to "Replace native environment with specified one". But Cevelop created the project with the PATH variable as appended with my global PATH:

global PATH : /usr/local/opt/llvm/bin/

project PATH : /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/llvm/bin/

Of course for the clang5.0 to be used by Cevelop I will need to edit the project PATH.

IMO this isn't the desired behavior.

Darnor commented 6 years ago

We'll look into this.

Darnor commented 6 years ago

This is an upstream issue, I've opened a new bug report here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=528891