Forum: Ruby-core [ruby-trunk - Bug #7485][Open] ruby cannot build on mingw32 due to missing __sync_val_compare_and_sw

Posted by drbrain (Eric Hodel) (Guest)
on 2012-11-30 23:39
(Received via mailing list)
Issue #7485 has been reported by drbrain (Eric Hodel).

----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by Nobuyoshi Nakada (nobu)
on 2012-12-01 00:42
(Received via mailing list)
Issue #7485 has been updated by nobu (Nobuyoshi Nakada).


__sync_or_and_fetch wasn't available in Apple derivative gcc.
----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34253

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by shyouhei (Shyouhei Urabe) (Guest)
on 2012-12-01 01:12
(Received via mailing list)
Issue #7485 has been updated by shyouhei (Shyouhei Urabe).


@nobu Why do we have to bother old broken compiler?
----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34256

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-12-01 05:55
(Received via mailing list)
Issue #7485 has been updated by kosaki (Motohiro KOSAKI).


I guess -march=i486 enable __sync_val_compare_and_swap.
----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34264

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by Nobuyoshi Nakada (nobu)
on 2012-12-02 02:44
(Received via mailing list)
Issue #7485 has been updated by nobu (Nobuyoshi Nakada).


Hmmm, if it can help, should add it by the default on mingw32?
----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34297

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by Luis Lavena (luislavena)
on 2012-12-02 10:20
(Received via mailing list)
Issue #7485 has been updated by luislavena (Luis Lavena).


Hello,

I just tested several native compilers on Windows 7 (without your patch) 
here are the results for those that define HAVE_GCC_ATOMIC_BUILTINS:

C:\Users\Luis\Code\ruby\ruby\build>gcc --version
gcc (tdm-1) 4.5.2

C:\Users\Luis\Code\ruby\ruby\build>cat 
.ext/include/i386-mingw32/ruby/config.h | grep ATOMIC
#define HAVE_GCC_ATOMIC_BUILTINS 1

C:\Users\Luis\Code\ruby\ruby\build>gcc --version
gcc (tdm-1) 4.6.1

C:\Users\Luis\Code\ruby\ruby\build>cat 
.ext/include/i386-mingw32/ruby/config.h | grep ATOMIC
#define HAVE_GCC_ATOMIC_BUILTINS 1

C:\Users\Luis\Code\ruby\ruby\build>gcc --version
gcc (rubenvb-4.7.2-release) 4.7.2

C:\Users\Luis\Code\ruby\ruby\build>cat 
.ext/include/i386-mingw32/ruby/config.h | grep ATOMIC
#define HAVE_GCC_ATOMIC_BUILTINS 1

In all scenarios it found the atomic builtins

On Windows XP (32bits), ATOMIC do get defined:

C:\Code\ruby\ruby\build>ver

Microsoft Windows XP [Version 5.1.2600]

C:\Code\ruby\ruby\build>gcc --version
gcc (rubenvb-4.7.2-release) 4.7.2

C:\Code\ruby\ruby\build>cat .ext\include\i386-mingw32\ruby\config.h | 
grep ATOMIC
#define HAVE_GCC_ATOMIC_BUILTINS 1

I was also able to compile Ruby without issues with "make all test"

I don't get the problem reported on this ticket on neither my systems.

I'm missing something?

Thank you.
----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34310

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by jonforums (Jon Forums) (Guest)
on 2012-12-02 16:57
(Received via mailing list)
Issue #7485 has been updated by jonforums (Jon Forums).


I agree with Luis' results and think we've just not fully debugged 
Eric's XP VM setup as in #7427.

With this snippet http://pastie.org/5460872 and Kosaki-san's feedback I 
see:

## mingw-w64 32bit gcc 4.7.2
C:\sandbox>gcc --version
gcc (rubenvb-4.7.2-release) 4.7.2

C:\sandbox>gcc -Wall -o atomics.exe gcc_atomic.c

C:\sandbox>atomics.exe
Got 1

C:\sandbox>gcc -Wall -march=i386 -o atomics.exe gcc_atomic.c
C:\Users\Jon\AppData\Local\Temp\ccK9GPwk.o:gcc_atomic.c:(.text+0x2e): 
undefined reference
to `__sync_val_compare_and_swap_4'
collect2.exe: error: ld returned 1 exit status


## mingw 32bit gcc 4.6.2
C:\sandbox>gcc --version
gcc (GCC) 4.6.2

C:\sandbox>gcc -Wall -o atomics.exe gcc_atomic.c
C:\Users\Jon\AppData\Local\Temp\ccpeH4Vt.o:gcc_atomic.c:(.text+0x2e): 
undefined reference
to `__sync_val_compare_and_swap_4'
collect2: ld returned 1 exit status

C:\sandbox>gcc -Wall -march={i486,i586,i686,native,core2} -o atomics.exe 
gcc_atomic.c

C:\Users\Jon\Documents\CDev\sandbox>atomics.exe
Got 1

Bottom line: even with these snippet results I see no build failures due 
to the current mingw32 build configuration.
----------------------------------------
Bug #7485: ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34322

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by drbrain (Eric Hodel) (Guest)
on 2012-12-12 02:37
(Received via mailing list)
Issue #7485 has been updated by drbrain (Eric Hodel).

Subject changed from ruby cannot build on mingw32 due to missing 
__sync_val_compare_and_swap to ruby cannot build on mingw32 or FreeBSD 8 
due to missing __sync_val_compare_and_swap


----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34644

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by drbrain (Eric Hodel) (Guest)
on 2012-12-12 02:42
(Received via mailing list)
Issue #7485 has been updated by drbrain (Eric Hodel).


=begin
I'm also experiencing this on FreeBSD 8 with gcc 4.2.1:

  $ gcc -v
  Using built-in specs.
  Target: i386-undermydesk-freebsd
  Configured with: FreeBSD/i386 system compiler
  Thread model: posix
  gcc version 4.2.1 20070719  [FreeBSD]
  $ make
  linking miniruby
  thread.o(.text+0x3f20): In function `rb_threadptr_execute_interrupts':
  /data/home/drbrain/Work/svn/ruby/thread.c:1807: undefined reference to 
`__sync_val_compare_and_swap_4'
  *** Error code 1

  Stop in /data/home/drbrain/Work/svn/ruby.

So it seems to be an old GCC issue, not a mingw-specific issue.

Is ruby 2.0 abandoning gcc 4.2.x?

=end

----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34645

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-12-12 03:07
(Received via mailing list)
Issue #7485 has been updated by kosaki (Motohiro KOSAKI).


Hi

Does following patch fix your issue?


diff --git a/configure.in b/configure.in
index c916cd5..4a34334 100644
--- a/configure.in
+++ b/configure.in
@@ -1534,7 +1534,7 @@ AS_CASE(["$target_os"],
 [])


-AS_CASE(["$target_cpu-$target_os"], [[i[3-6]86-linux*]], [
+AS_CASE(["$target_cpu-$target_os"], [[i[3-6]86-*]], [
         AC_CACHE_CHECK([for __sync_val_compare_and_swap], [rb_cv_gcc_co
                         AC_TRY_LINK([unsigned long atomic_var;],
                                     [

----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34646

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by drbrain (Eric Hodel) (Guest)
on 2012-12-14 02:05
(Received via mailing list)
Issue #7485 has been updated by drbrain (Eric Hodel).


This patch works, thanks!
----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34727

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-12-14 09:36
(Received via mailing list)
Issue #7485 has been updated by kosaki (Motohiro KOSAKI).

Status changed from Open to Assigned
Assignee changed from nobu (Nobuyoshi Nakada) to drbrain (Eric Hodel)

@drbrain, could you please commit the patch instead of me? I have no 
test environment and I don't like commit w/o make test-all.


----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34738

Author: drbrain (Eric Hodel)
Status: Assigned
Priority: Normal
Assignee: drbrain (Eric Hodel)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by drbrain (Eric Hodel) (Guest)
on 2012-12-14 20:21
(Received via mailing list)
Issue #7485 has been updated by drbrain (Eric Hodel).


I have confirmed it fixes mingw32 as well, I will commit it after lunch. 
Thanks for the patch!
----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34749

Author: drbrain (Eric Hodel)
Status: Assigned
Priority: Normal
Assignee: drbrain (Eric Hodel)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by drbrain (Eric Hodel) (Guest)
on 2012-12-14 22:22
(Received via mailing list)
Issue #7485 has been updated by drbrain (Eric Hodel).


Please check my ChangeLog message for accuracy.
----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34751

Author: drbrain (Eric Hodel)
Status: Closed
Priority: Normal
Assignee: drbrain (Eric Hodel)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-12-14 22:38
(Received via mailing list)
Issue #7485 has been updated by kosaki (Motohiro KOSAKI).


> Please check my ChangeLog message for accuracy.

Looks correct. thank you!
----------------------------------------
Bug #7485: ruby cannot build on mingw32 or FreeBSD 8 due to missing 
__sync_val_compare_and_swap
https://bugs.ruby-lang.org/issues/7485#change-34752

Author: drbrain (Eric Hodel)
Status: Closed
Priority: Normal
Assignee: drbrain (Eric Hodel)
Category: build
Target version: 2.0.0
ruby -v: trunk


mingw32 GCC has the other atomic builtins but not this one.  The 
attached patch checks for the GCC builtins used in ruby_atomic.h but not 
checked for by configure.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.