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

gcc 4.9.3 problem #2665

Closed
d3vv opened this issue May 7, 2020 · 4 comments
Closed

gcc 4.9.3 problem #2665

d3vv opened this issue May 7, 2020 · 4 comments

Comments

@d3vv
Copy link

d3vv commented May 7, 2020

g++ -Wall -Wcast-qual -fno-exceptions -std=c++11 -fprofile-generate -pedantic -Wextra -Wshadow -m64 -DNDEBUG -O3 -DIS_64BIT -msse -flto   -c -o misc.o misc.cpp
misc.cpp: In function ‘void* aligned_ttmem_alloc(size_t, void*&)’:
misc.cpp:306:38: error: ‘aligned_alloc’ was not declared in this scope
   mem = aligned_alloc(alignment, size);
@vondele
Copy link
Member

vondele commented May 8, 2020

https://gcc.gnu.org/develop.html#timeline so that's a rather old gcc (first released 2014). But it might actually be a feature of your glibc and/or OS, where we expect that function to be available via stdlib.h :
https://linux.die.net/man/3/aligned_alloc
I think we had some discussion on this when this feature was merged.

The easiest standard conforming way would be to upgrade to c++17 .... but that doesn't help gcc 4.9.3 either.

Do you have a suggestion how this could be fixed (basically, I think we need an additional condition on the define that uses the code).

@d3vv
Copy link
Author

d3vv commented May 8, 2020

Just I have glibc-2.15, and

The function aligned_alloc() was added to glibc in version 2.16

Many legacy servers can't be upgraded
And as for me I have used posix_memalign() for cross platform compatibility as well..

@vondele
Copy link
Member

vondele commented May 8, 2020

so on your system, can you test if the code works with posix_memalign ?

I wonder if there are linux systems where aligned_alloc works but not posix_memalign.

@d3vv
Copy link
Author

d3vv commented May 8, 2020

@vondele yes, it works for me:

misc.cpp: In function ‘void* aligned_ttmem_alloc(size_t, void*&)’:
misc.cpp:306:40: warning: ignoring return value of ‘int posix_memalign(void**, size_t, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
   posix_memalign(&mem, alignment, size); //mem = aligned_alloc(alignment, size);

Have the same bench:

Nodes searched : 5185517

vondele added a commit to vondele/Stockfish that referenced this issue May 9, 2020
should be a little more portable to older linux systems (before glibc-2.16).

fixes official-stockfish#2665

No functional change.
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

Successfully merging a pull request may close this issue.

2 participants