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 cannot be compiled with --threads:on #2620

Closed
bluenote10 opened this issue Apr 29, 2015 · 7 comments
Closed

C code cannot be compiled with --threads:on #2620

bluenote10 opened this issue Apr 29, 2015 · 7 comments

Comments

@bluenote10
Copy link
Contributor

When using --threads:on I cannot compile even a simple echo "Hello World". The C compilation fails with:

.../nimcache/stdlib_system.c: In function ‘atomicinc_14401’:
.../nimcache/stdlib_system.c:6097:41: error: ‘__ATOMIC_RELAXED’ undeclared (first use in this function)
.../nimcache/stdlib_system.c:6097:41: note: each undeclared identifier is reported only once for each function it appears in
.../nimcache/stdlib_system.c: In function ‘atomicdec_14406’:
.../nimcache/stdlib_system.c:6104:41: error: ‘__ATOMIC_RELAXED’ undeclared (first use in this function)

Version: latest devel 26eae7d

This was the true cause of #2619.

@bluenote10
Copy link
Contributor Author

It turns out that this problem is caused by the GCC version, which is 4.6.3 in my case. The atomic builtins referenced in atomic.nim are only available with GCC 4.7+. I was trying to implement AtomMemModel as enum (as it was in this earlier version), but this still leaves undeclared identifiers for all the function calls.

@dom96
Copy link
Contributor

dom96 commented May 21, 2015

Can this be closed?

@bluenote10
Copy link
Contributor Author

From my point of view: Yes, problem solved by using a more recent GCC.

But it probably depends on which GCC versions to target. Not sure what the plans are in general. I remember Araq consider fixing it. GCC 4.6 is still the default for Ubuntu 12.04, which may still be around until 2017 (where support ends), so we can expect others to run into this. I guess the simplest solution is to deprecate GCC 4.6, mention it in the manual, and produce a meaningful error "GCC version too old". The real issue here is probably just the error message, since it is rather difficult to see the actual cause behind these "undeclared" errors.

@dom96
Copy link
Contributor

dom96 commented May 21, 2015

I'll leave this open so that we can hopefully improve the error message.

@Varriount
Copy link
Contributor

How would we do that? The error occurs when handling control of compilation over to gcc.

@dom96
Copy link
Contributor

dom96 commented May 22, 2015

@Varriount many different options. Off the top of my head: generate a macro in the C code which checks for the presence of __ATOMIC_RELAXED (and creates a nice error when it doesn't exist), get the Nim compiler to run gcc -v to check the version of gcc on the system.

@bluenote10
Copy link
Contributor Author

Closing this in favor of #5992

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

No branches or pull requests

3 participants