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

C++ code fails under GNAT 2018 #44

Closed
rogermc2 opened this issue Jun 26, 2018 · 13 comments
Closed

C++ code fails under GNAT 2018 #44

rogermc2 opened this issue Jun 26, 2018 · 13 comments

Comments

@rogermc2
Copy link

I am trying build a simple program using GNAT 2018 GPS that involves ImageMagick read functions.
The program builds and runs using Xcode but fails under GNAT 2018.
The problem seems to be associated with the ImageMagick read functions, most likely string functions involved with the use of the file name.
At one stage I ascertained that a segmentation fault seemed to be caused by a string swap function being called with a null string address.
As I experience no problems with Xcode, I have tried to generate a config file to make GNAT GPS use the llvm (clang and clang++) compilers instead of the gcc compilers but have been unsuccessful in doing so.
I will very much appreciate any assistance in generating a suitable config file or other advice.

@t-14
Copy link
Contributor

t-14 commented Jun 26, 2018

I think the following should give what you want: gprconfig --config=language:c,name:llvm --batch

@t-14 t-14 closed this as completed Jun 26, 2018
@rogermc2
Copy link
Author

rogermc2 commented Jun 26, 2018

I tried gprconfig --config=language:c,name:llvm --batch
But:
Error: unknown language 'language:c'

However,
gprconfig --config=c --config=c++ name:llvm --batch is accepted
but .cgpr file still contains:
for Driver ("C") use "/usr/bin/clang";
for Driver ("C++") use "/opt/gnat/2018/bin/g++";

@t-14
Copy link
Contributor

t-14 commented Jun 26, 2018

Instructions implied up-to-date gprbuild. If it's older, use the following switch instead (note: should be upper case actually) --config=c,,,,LLVM

Looks like we are missing a line to do the same for C++. Add in compilers.xml in LLVM block the following: <languages>C++</languages> - then you should be able to also do --config=c++,,,,LLVM

We will add it too.

@rogermc2
Copy link
Author

rogermc2 commented Jun 27, 2018

I tried adding C++ in few different positions of the LLVM block of compilers.xml including C,C++ as specified by section 4.1. Configuring with GPRconfig of the manual but whenever I try to compile a C++ file I get

gprbuild: raised CONSTRAINT_ERROR : gprbuild-compile.adb:3418:74 access check failed
Load address: 0x10aca6000
Call stack traceback locations:
0x10ad0c085 0x10ad11f0c 0x10ad139bf 0x10ad1455c 0x10acb841d 0x10b1c95a1

@rogermc2
Copy link
Author

rogermc2 commented Jun 27, 2018

gprconfig --version
GPRCONFIG Community 2018 (20180523) (x86_64-apple-darwin16.7.0)

I finally got it to work without adding <languages>C++</languages> but by changing
for Driver ("C++") use "/opt/gnat/2018/bin/g++";
to
for Driver ("C++") use "/usr/bin/clang";
in the .cprg file generated by gprconfig.
However, compilation does produce the following warning:
clang: warning: argument unused during compilation: '-specs=/private/var/folders/q8/7v9djkh9021057yz0yldxvmr0000gn/T/GNAT-TEMP-000002.TMP' [-Wunused-command-line-argument]

Thanks for your help

@t-14
Copy link
Contributor

t-14 commented Jun 27, 2018

To use LLVM for C++ you need the latest knowledge base, in particular this patch: eb94de5 - without it it won't work properly (though I can't reproduce the crash).

I finally got it to work without adding C++ but by changing

I don't think that's a good idea. You need to have a consistent KB.

@rogermc2
Copy link
Author

I agree that changing the config file is not a good idea but its the only solution that I've got at the moment.
Is it possible for me to obtain the latest knowledge base or implement the patch?
Thanks

@t-14
Copy link
Contributor

t-14 commented Jun 27, 2018

Is it possible for me to obtain the latest knowledge base

It's this repository ;) (share/gprconfig subdir)

@rogermc2
Copy link
Author

rogermc2 commented Jun 28, 2018

I downloaded gprbuild-master and copied share/gprconfig into my GNAT/2018/share directory.
However, when I run gprconfig I still only get
G++ for C++ in /usr/local/bin/ and G++ for C++ in /opt/gnat/2018/bin/ version 7.3.1 options for C++.
Is there something else that I need to do?
Thanks.

@t-14
Copy link
Contributor

t-14 commented Jun 28, 2018

You still need to apply the aforementioned patch (<languages>C++</languages>) on top of it - we said we'll do it but didn't get to it yet.

@rogermc2
Copy link
Author

rogermc2 commented Jun 28, 2018

I've just manually checked the gprconfig files that I downloaded from the share/gprconfig subdir against patch eb94de5 and the files appear to include the patch.
As its a while since I've used the unix patch facility, it would take me a while to refamiliarize myself with checking and applying patches.
Or is the "aforementioned patch (<languages>C++</languages>) " a different patch? (Probably not as <languages>C++</languages> does appear in eb94de5.)

adacore-bot pushed a commit that referenced this issue Jun 28, 2018
TN: QB10-015
GitHub issue #44

Change-Id: I651393950c2f0031a2e948af0a1c9c225c523af3
@t-14
Copy link
Contributor

t-14 commented Jun 28, 2018

It's what I was referring to here:

Looks like we are missing a line to do the same for C++. Add in compilers.xml in LLVM block the following: <languages>C++</languages> - then you should be able to also do --config=c++,,,,LLVM

We just pushed this change so you can just resync.

@rogermc2
Copy link
Author

rogermc2 commented Jun 29, 2018

Great! I downloaded, built and installed your latest gprbuild-master and ran the new gprbuild selecting the llVM C and C++ compilers.
The test program I've been having problems with now works completely under GPS.
Not only that, the Ada test program that interfaces with the C++ code also works. Having this work is fundamental to my main project.
Many thanks.

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

No branches or pull requests

2 participants