Porting to OS/2: Case #8 atomic builtins

From time to time, you may encounter the following error when compiling.

Undefined symbol ___sync_val_compare_and_swap_4 referenced from text segment

This function is an atomic builtin of gcc. Nevertheless, even though you are using the latest gcc, this may occur. This is because this atomic builtin enabled only at i486 cpu or later, but the default architect of OS/2 gcc is i386. If you want to confirm the architect of your gcc, do this.

  • gcc -E -dM - < nul

And you can find __tune_i386__. Now add -march=i486.

  • gcc -march=i486 -E -dM - < nul

Then, you can find __tune_i486__ instead of __tune_i386__. In addition, you can find another differences. Especially,

1
2
3
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1


Consequently, if you encounter that error, then add -march=i486 to your compiler flags. For references, atomic builtins of gcc have __sync_ prefix, or visit here for details.



댓글

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷