ffi 1.17.2 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +25 -0
  4. data/Gemfile +7 -4
  5. data/README.md +1 -0
  6. data/Rakefile +7 -4
  7. data/Steepfile +8 -0
  8. data/ext/ffi_c/DynamicLibrary.c +1 -1
  9. data/ext/ffi_c/Function.c +2 -0
  10. data/ext/ffi_c/MethodHandle.c +4 -2
  11. data/ext/ffi_c/libffi/.ci/Containerfile.ppc64le +12 -0
  12. data/ext/ffi_c/libffi/.ci/build.sh +38 -33
  13. data/ext/ffi_c/libffi/.ci/install.sh +46 -50
  14. data/ext/ffi_c/libffi/.ci/site.exp +6 -0
  15. data/ext/ffi_c/libffi/.gail-labels +44 -0
  16. data/ext/ffi_c/libffi/.github/workflows/build.yml +212 -333
  17. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +58 -3
  18. data/ext/ffi_c/libffi/.github/workflows/label-new-issue.yaml +15 -0
  19. data/ext/ffi_c/libffi/.github/workflows/tarball.yml +55 -0
  20. data/ext/ffi_c/libffi/LICENSE +1 -1
  21. data/ext/ffi_c/libffi/Makefile.am +17 -13
  22. data/ext/ffi_c/libffi/Makefile.in +37 -30
  23. data/ext/ffi_c/libffi/README.md +22 -3
  24. data/ext/ffi_c/libffi/configure +105 -121
  25. data/ext/ffi_c/libffi/configure.ac +21 -8
  26. data/ext/ffi_c/libffi/configure.host +6 -1
  27. data/ext/ffi_c/libffi/doc/Makefile.in +3 -0
  28. data/ext/ffi_c/libffi/doc/libffi.texi +24 -1
  29. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  30. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -28
  31. data/ext/ffi_c/libffi/include/Makefile.in +3 -0
  32. data/ext/ffi_c/libffi/include/ffi.h.in +19 -1
  33. data/ext/ffi_c/libffi/libffi.map.in +13 -1
  34. data/ext/ffi_c/libffi/libtool-version +1 -1
  35. data/ext/ffi_c/libffi/m4/asmcfi.m4 +28 -11
  36. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +13 -3
  37. data/ext/ffi_c/libffi/man/Makefile.in +3 -0
  38. data/ext/ffi_c/libffi/src/aarch64/sysv.S +7 -1
  39. data/ext/ffi_c/libffi/src/arm/sysv.S +1 -1
  40. data/ext/ffi_c/libffi/src/pa/linux.S +4 -0
  41. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -0
  42. data/ext/ffi_c/libffi/src/riscv/ffi.c +39 -16
  43. data/ext/ffi_c/libffi/src/riscv/internal.h +7 -0
  44. data/ext/ffi_c/libffi/src/riscv/sysv.S +24 -0
  45. data/ext/ffi_c/libffi/src/tramp.c +6 -1
  46. data/ext/ffi_c/libffi/src/types.c +23 -1
  47. data/ext/ffi_c/libffi/src/{wasm32 → wasm}/ffi.c +157 -54
  48. data/ext/ffi_c/libffi/src/{wasm32 → wasm}/ffitarget.h +17 -0
  49. data/ext/ffi_c/libffi/src/x86/ffitarget.h +0 -3
  50. data/ext/ffi_c/libffi/src/x86/sysv.S +1 -3
  51. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +1 -3
  52. data/ext/ffi_c/libffi/testsuite/Makefile.am +3 -2
  53. data/ext/ffi_c/libffi/testsuite/Makefile.in +6 -2
  54. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +2 -2
  55. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +4 -4
  56. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +269 -256
  57. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +1 -1
  58. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +3 -0
  59. data/ext/ffi_c/libffi/testsuite/libffi.call/longjmp.c +60 -0
  60. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +1 -1
  61. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +1 -2
  62. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -0
  63. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +2 -0
  64. data/ext/ffi_c/libffi/testsuite/libffi.threads/ffitest.h +1 -0
  65. data/ext/ffi_c/libffi/testsuite/libffi.threads/threads.exp +50 -0
  66. data/ext/ffi_c/libffi/testsuite/libffi.threads/tsan.c +74 -0
  67. data/ext/ffi_c/libffi.mk +5 -0
  68. data/ffi.gemspec +4 -5
  69. data/lib/ffi/autopointer.rb +6 -0
  70. data/lib/ffi/compat.rb +11 -0
  71. data/lib/ffi/function.rb +23 -0
  72. data/lib/ffi/library.rb +19 -3
  73. data/lib/ffi/struct_by_reference.rb +1 -1
  74. data/lib/ffi/version.rb +1 -1
  75. data/samples/hello_ractor.rb +9 -1
  76. data/samples/qsort_ractor.rb +9 -1
  77. data/sig/ffi/auto_pointer.rbs +1 -1
  78. data/sig/ffi/errno.rbs +8 -0
  79. data/sig/ffi/platform.rbs +49 -0
  80. data/sig/ffi/struct.rbs +2 -2
  81. data/sig/ffi/struct_by_reference.rbs +1 -1
  82. data/sig/ffi.rbs +4 -1
  83. data.tar.gz.sig +0 -0
  84. metadata +33 -79
  85. metadata.gz.sig +0 -0
  86. data/ext/ffi_c/libffi/.appveyor/site.exp +0 -16
  87. data/ext/ffi_c/libffi/.appveyor.yml +0 -84
  88. data/lib/ffi/tools/types_generator.rb +0 -137
  89. data/rakelib/ffi_gem_helper.rb +0 -65
  90. /data/ext/ffi_c/libffi/{.appveyor → .ci}/unix-noexec.exp +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011, 2014, 2019, 2022 Free Software Foundation, Inc.
1
+ # Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011, 2014, 2019, 2022, 2025 Free Software Foundation, Inc.
2
2
 
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -38,14 +38,14 @@ proc is-effective-target { arg } {
38
38
  global et_index
39
39
  set selected 0
40
40
  if { ![info exists et_index] } {
41
- # Initialize the effective target index that is used in some
42
- # check_effective_target_* procs.
43
- set et_index 0
41
+ # Initialize the effective target index that is used in some
42
+ # check_effective_target_* procs.
43
+ set et_index 0
44
44
  }
45
45
  if { [info procs check_effective_target_${arg}] != [list] } {
46
- set selected [check_effective_target_${arg}]
46
+ set selected [check_effective_target_${arg}]
47
47
  } else {
48
- error "unknown effective target keyword `$arg'"
48
+ error "unknown effective target keyword `$arg'"
49
49
  }
50
50
  verbose "is-effective-target: $arg $selected" 2
51
51
  return $selected
@@ -53,9 +53,9 @@ proc is-effective-target { arg } {
53
53
 
54
54
  proc is-effective-target-keyword { arg } {
55
55
  if { [info procs check_effective_target_${arg}] != [list] } {
56
- return 1
56
+ return 1
57
57
  } else {
58
- return 0
58
+ return 0
59
59
  }
60
60
  }
61
61
 
@@ -87,93 +87,93 @@ if { [info procs saved-dg-process-target] == [list] } {
87
87
 
88
88
  # Evaluate an operand within a selector expression.
89
89
  proc selector_opd { op } {
90
- set selector "target"
91
- lappend selector $op
92
- set answer [ expr { [dg-process-target $selector] == "S" } ]
93
- verbose "selector_opd: `$op' $answer" 2
94
- return $answer
90
+ set selector "target"
91
+ lappend selector $op
92
+ set answer [ expr { [dg-process-target $selector] == "S" } ]
93
+ verbose "selector_opd: `$op' $answer" 2
94
+ return $answer
95
95
  }
96
96
 
97
97
  # Evaluate a target triplet list within a selector expression.
98
98
  # Unlike other operands, this needs to be expanded from a list to
99
99
  # the same string as "target".
100
100
  proc selector_list { op } {
101
- set selector "target [join $op]"
102
- set answer [ expr { [dg-process-target $selector] == "S" } ]
103
- verbose "selector_list: `$op' $answer" 2
104
- return $answer
101
+ set selector "target [join $op]"
102
+ set answer [ expr { [dg-process-target $selector] == "S" } ]
103
+ verbose "selector_list: `$op' $answer" 2
104
+ return $answer
105
105
  }
106
106
 
107
107
  # Evaluate a selector expression.
108
108
  proc selector_expression { exp } {
109
- if { [llength $exp] == 2 } {
110
- if [string match "!" [lindex $exp 0]] {
111
- set op1 [lindex $exp 1]
112
- set answer [expr { ! [selector_opd $op1] }]
113
- } else {
114
- # Assume it's a list of target triplets.
115
- set answer [selector_list $exp]
116
- }
117
- } elseif { [llength $exp] == 3 } {
118
- set op1 [lindex $exp 0]
119
- set opr [lindex $exp 1]
120
- set op2 [lindex $exp 2]
121
- if [string match "&&" $opr] {
122
- set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
123
- } elseif [string match "||" $opr] {
124
- set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
125
- } else {
126
- # Assume it's a list of target triplets.
127
- set answer [selector_list $exp]
128
- }
129
- } else {
130
- # Assume it's a list of target triplets.
131
- set answer [selector_list $exp]
132
- }
133
-
134
- verbose "selector_expression: `$exp' $answer" 2
135
- return $answer
109
+ if { [llength $exp] == 2 } {
110
+ if [string match "!" [lindex $exp 0]] {
111
+ set op1 [lindex $exp 1]
112
+ set answer [expr { ! [selector_opd $op1] }]
113
+ } else {
114
+ # Assume it's a list of target triplets.
115
+ set answer [selector_list $exp]
116
+ }
117
+ } elseif { [llength $exp] == 3 } {
118
+ set op1 [lindex $exp 0]
119
+ set opr [lindex $exp 1]
120
+ set op2 [lindex $exp 2]
121
+ if [string match "&&" $opr] {
122
+ set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
123
+ } elseif [string match "||" $opr] {
124
+ set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
125
+ } else {
126
+ # Assume it's a list of target triplets.
127
+ set answer [selector_list $exp]
128
+ }
129
+ } else {
130
+ # Assume it's a list of target triplets.
131
+ set answer [selector_list $exp]
132
+ }
133
+
134
+ verbose "selector_expression: `$exp' $answer" 2
135
+ return $answer
136
136
  }
137
137
 
138
138
  # Evaluate "target selector" or "xfail selector".
139
139
 
140
140
  proc dg-process-target-1 { args } {
141
- verbose "dg-process-target-1: `$args'" 2
142
-
143
- # Extract the 'what' keyword from the argument list.
144
- set selector [string trim [lindex $args 0]]
145
- if [regexp "^xfail " $selector] {
146
- set what "xfail"
147
- } elseif [regexp "^target " $selector] {
148
- set what "target"
149
- } else {
150
- error "syntax error in target selector \"$selector\""
151
- }
152
-
153
- # Extract the rest of the list, which might be a keyword.
154
- regsub "^${what}" $selector "" rest
155
- set rest [string trim $rest]
156
-
157
- if [is-effective-target-keyword $rest] {
158
- # The selector is an effective target keyword.
159
- if [is-effective-target $rest] {
160
- return [expr { $what == "xfail" ? "F" : "S" }]
161
- } else {
162
- return [expr { $what == "xfail" ? "P" : "N" }]
163
- }
164
- }
165
-
166
- if [string match "{*}" $rest] {
167
- if [selector_expression [lindex $rest 0]] {
168
- return [expr { $what == "xfail" ? "F" : "S" }]
169
- } else {
170
- return [expr { $what == "xfail" ? "P" : "N" }]
171
- }
172
- }
173
-
174
- # The selector is not an effective-target keyword, so process
175
- # the list of target triplets.
176
- return [saved-dg-process-target $selector]
141
+ verbose "dg-process-target-1: `$args'" 2
142
+
143
+ # Extract the 'what' keyword from the argument list.
144
+ set selector [string trim [lindex $args 0]]
145
+ if [regexp "^xfail " $selector] {
146
+ set what "xfail"
147
+ } elseif [regexp "^target " $selector] {
148
+ set what "target"
149
+ } else {
150
+ error "syntax error in target selector \"$selector\""
151
+ }
152
+
153
+ # Extract the rest of the list, which might be a keyword.
154
+ regsub "^${what}" $selector "" rest
155
+ set rest [string trim $rest]
156
+
157
+ if [is-effective-target-keyword $rest] {
158
+ # The selector is an effective target keyword.
159
+ if [is-effective-target $rest] {
160
+ return [expr { $what == "xfail" ? "F" : "S" }]
161
+ } else {
162
+ return [expr { $what == "xfail" ? "P" : "N" }]
163
+ }
164
+ }
165
+
166
+ if [string match "{*}" $rest] {
167
+ if [selector_expression [lindex $rest 0]] {
168
+ return [expr { $what == "xfail" ? "F" : "S" }]
169
+ } else {
170
+ return [expr { $what == "xfail" ? "P" : "N" }]
171
+ }
172
+ }
173
+
174
+ # The selector is not an effective-target keyword, so process
175
+ # the list of target triplets.
176
+ return [saved-dg-process-target $selector]
177
177
  }
178
178
 
179
179
  # Intercept calls to the DejaGnu function. In addition to
@@ -181,24 +181,24 @@ if { [info procs saved-dg-process-target] == [list] } {
181
181
  # "target selector1 xfail selector2".
182
182
 
183
183
  proc dg-process-target { args } {
184
- verbose "replacement dg-process-target: `$args'" 2
185
-
186
- set selector [string trim [lindex $args 0]]
187
-
188
- # If the argument list contains both 'target' and 'xfail',
189
- # process 'target' and, if that succeeds, process 'xfail'.
190
- if [regexp "^target .* xfail .*" $selector] {
191
- set xfail_index [string first "xfail" $selector]
192
- set xfail_selector [string range $selector $xfail_index end]
193
- set target_selector [string range $selector 0 [expr $xfail_index-1]]
194
- set target_selector [string trim $target_selector]
195
- if { [dg-process-target-1 $target_selector] == "N" } {
196
- return "N"
197
- }
198
- return [dg-process-target-1 $xfail_selector]
184
+ verbose "replacement dg-process-target: `$args'" 2
185
+
186
+ set selector [string trim [lindex $args 0]]
187
+
188
+ # If the argument list contains both 'target' and 'xfail',
189
+ # process 'target' and, if that succeeds, process 'xfail'.
190
+ if [regexp "^target .* xfail .*" $selector] {
191
+ set xfail_index [string first "xfail" $selector]
192
+ set xfail_selector [string range $selector $xfail_index end]
193
+ set target_selector [string range $selector 0 [expr $xfail_index-1]]
194
+ set target_selector [string trim $target_selector]
195
+ if { [dg-process-target-1 $target_selector] == "N" } {
196
+ return "N"
197
+ }
198
+ return [dg-process-target-1 $xfail_selector]
199
199
 
200
- }
201
- return [dg-process-target-1 $selector]
200
+ }
201
+ return [dg-process-target-1 $selector]
202
202
  }
203
203
  }
204
204
 
@@ -217,8 +217,8 @@ proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } {
217
217
  upvar 2 dg-output-text output_match
218
218
 
219
219
  if { [llength $output_match] > 1 } {
220
- regsub -all "\n" [lindex $output_match 1] "\r?\n" x
221
- set output_match [lreplace $output_match 1 1 $x]
220
+ regsub -all "\n" [lindex $output_match 1] "\r?\n" x
221
+ set output_match [lreplace $output_match 1 1 $x]
222
222
  }
223
223
 
224
224
  if { [ istarget "wasm32-*-*" ] } {
@@ -232,34 +232,34 @@ proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } {
232
232
 
233
233
  set options [list]
234
234
  switch $do_what {
235
- "compile" {
236
- set compile_type "assembly"
237
- set output_file "[file rootname [file tail $prog]].s"
238
- }
239
- "link" {
240
- set compile_type "executable"
241
- set output_file "[file rootname [file tail $prog]]$exec_suffix"
242
- # The following line is needed for targets like the i960 where
243
- # the default output file is b.out. Sigh.
244
- }
245
- "run" {
246
- set compile_type "executable"
247
- # FIXME: "./" is to cope with "." not being in $PATH.
248
- # Should this be handled elsewhere?
249
- # YES.
250
- set output_file "./[file rootname [file tail $prog]]$exec_suffix"
251
- # This is the only place where we care if an executable was
252
- # created or not. If it was, dg.exp will try to run it.
253
- remote_file build delete $output_file;
254
- }
255
- default {
256
- perror "$do_what: not a valid dg-do keyword"
257
- return ""
258
- }
235
+ "compile" {
236
+ set compile_type "assembly"
237
+ set output_file "[file rootname [file tail $prog]].s"
238
+ }
239
+ "link" {
240
+ set compile_type "executable"
241
+ set output_file "[file rootname [file tail $prog]]$exec_suffix"
242
+ # The following line is needed for targets like the i960 where
243
+ # the default output file is b.out. Sigh.
244
+ }
245
+ "run" {
246
+ set compile_type "executable"
247
+ # FIXME: "./" is to cope with "." not being in $PATH.
248
+ # Should this be handled elsewhere?
249
+ # YES.
250
+ set output_file "./[file rootname [file tail $prog]]$exec_suffix"
251
+ # This is the only place where we care if an executable was
252
+ # created or not. If it was, dg.exp will try to run it.
253
+ remote_file build delete $output_file;
254
+ }
255
+ default {
256
+ perror "$do_what: not a valid dg-do keyword"
257
+ return ""
258
+ }
259
259
  }
260
260
 
261
261
  if { $extra_tool_flags != "" } {
262
- lappend options "additional_flags=$extra_tool_flags"
262
+ lappend options "additional_flags=$extra_tool_flags"
263
263
  }
264
264
 
265
265
  set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options];
@@ -297,7 +297,7 @@ proc libffi-init { args } {
297
297
  global compiler_vendor
298
298
 
299
299
  if ![info exists blddirffi] {
300
- set blddirffi [pwd]/..
300
+ set blddirffi [pwd]/..
301
301
  }
302
302
 
303
303
  verbose "libffi $blddirffi"
@@ -306,7 +306,7 @@ proc libffi-init { args } {
306
306
  if { [string match $compiler_vendor "gnu"] } {
307
307
  set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
308
308
  if {$gccdir != ""} {
309
- set gccdir [file dirname $gccdir]
309
+ set gccdir [file dirname $gccdir]
310
310
  }
311
311
  verbose "gccdir $gccdir"
312
312
 
@@ -315,17 +315,17 @@ proc libffi-init { args } {
315
315
 
316
316
  set compiler "${gccdir}/xgcc"
317
317
  if { [is_remote host] == 0 && [which $compiler] != 0 } {
318
- foreach i "[exec $compiler --print-multi-lib]" {
319
- set mldir ""
320
- regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
321
- set mldir [string trimright $mldir "\;@"]
322
- if { "$mldir" == "." } {
323
- continue
324
- }
325
- if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
326
- append ld_library_path ":${gccdir}/${mldir}"
327
- }
328
- }
318
+ foreach i "[exec $compiler --print-multi-lib]" {
319
+ set mldir ""
320
+ regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
321
+ set mldir [string trimright $mldir "\;@"]
322
+ if { "$mldir" == "." } {
323
+ continue
324
+ }
325
+ if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
326
+ append ld_library_path ":${gccdir}/${mldir}"
327
+ }
328
+ }
329
329
  }
330
330
  }
331
331
 
@@ -341,8 +341,8 @@ proc libffi-init { args } {
341
341
  set libffi_dir "${blddirffi}/.libs"
342
342
  verbose "libffi_dir $libffi_dir"
343
343
  if { $libffi_dir != "" } {
344
- set libffi_dir [file dirname ${libffi_dir}]
345
- set libffi_link_flags "-L${libffi_dir}/.libs"
344
+ set libffi_dir [file dirname ${libffi_dir}]
345
+ set libffi_link_flags "-L ../.libs"
346
346
  }
347
347
 
348
348
  set_ld_library_path_env_vars
@@ -353,8 +353,8 @@ proc libffi_exit { } {
353
353
  global gluefile;
354
354
 
355
355
  if [info exists gluefile] {
356
- file_on_build delete $gluefile;
357
- unset gluefile;
356
+ file_on_build delete $gluefile;
357
+ unset gluefile;
358
358
  }
359
359
  }
360
360
 
@@ -369,54 +369,64 @@ proc libffi_target_compile { source dest type options } {
369
369
  global compiler_vendor
370
370
 
371
371
  if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
372
- lappend options "libs=${gluefile}"
373
- lappend options "ldflags=$wrap_flags"
372
+ lappend options "libs=${gluefile}"
373
+ lappend options "ldflags=$wrap_flags"
374
374
  }
375
375
 
376
376
  # TOOL_OPTIONS must come first, so that it doesn't override testcase
377
377
  # specific options.
378
378
  if [info exists TOOL_OPTIONS] {
379
- lappend options "additional_flags=$TOOL_OPTIONS"
379
+ lappend options "additional_flags=$TOOL_OPTIONS"
380
380
  }
381
381
 
382
382
  # search for ffi_mips.h in srcdir, too
383
- lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.."
384
- lappend options "additional_flags=${libffi_link_flags}"
385
-
386
- # Darwin needs a stack execution allowed flag.
387
-
388
- if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"]
389
- || [istarget "*-*-darwin2*"] } {
390
- # lappend options "additional_flags=-Wl,-allow_stack_execute"
391
- lappend options "additional_flags=-Wno-unused-command-line-argument"
392
- lappend options "additional_flags=-Wl,-search_paths_first"
393
- }
383
+ # lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.."
384
+ lappend options "additional_flags=-I ../include -I ${srcdir}/../include -I .."
385
+ if { [string match $type "executable"] } {
386
+
387
+ lappend options "additional_flags=${libffi_link_flags}"
388
+
389
+ # Darwin needs a stack execution allowed flag.
390
+ if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"]
391
+ || [istarget "*-*-darwin2*"] } {
392
+ # lappend options "additional_flags=-Wl,-allow_stack_execute"
393
+ lappend options "additional_flags=-Wno-unused-command-line-argument"
394
+ lappend options "additional_flags=-Wl,-search_paths_first"
395
+ }
394
396
 
395
- # If you're building the compiler with --prefix set to a place
396
- # where it's not yet installed, then the linker won't be able to
397
- # find the libgcc used by libffi.dylib. We could pass the
398
- # -dylib_file option, but that's complicated, and it's much easier
399
- # to just make the linker find libgcc using -L options.
400
- if { [string match "*-*-darwin*" $target_triplet] } {
401
- lappend options "libs= -shared-libgcc"
402
- }
397
+ # If you're building the compiler with --prefix set to a place
398
+ # where it's not yet installed, then the linker won't be able to
399
+ # find the libgcc used by libffi.dylib. We could pass the
400
+ # -dylib_file option, but that's complicated, and it's much easier
401
+ # to just make the linker find libgcc using -L options.
402
+ if { [string match "*-*-darwin*" $target_triplet] } {
403
+ lappend options "libs= -shared-libgcc"
404
+ }
403
405
 
404
- if { [string match "*-*-openbsd*" $target_triplet] } {
405
- lappend options "libs= -lpthread"
406
- }
406
+ if { [string match "*-*-openbsd*" $target_triplet] } {
407
+ lappend options "libs= -lpthread"
408
+ }
407
409
 
408
- lappend options "libs= -lffi"
410
+ if { [string match "*-*-freebsd*" $target_triplet] } {
411
+ lappend options "libs= -lpthread"
412
+ }
409
413
 
410
- if { ![string match "*android*" $target_triplet] } {
414
+ lappend options "libs= -lffi"
411
415
 
412
416
  if { [string match "aarch64*-*-linux*" $target_triplet] } {
413
- lappend options "libs= -lpthread"
417
+ if { ! [string match "*android*" $target_triplet] } {
418
+ lappend options "libs= -lpthread"
419
+ }
414
420
  }
415
421
 
416
422
  # this may be required for g++, but just confused clang.
417
423
  if { [string match "*.cc" $source] } {
418
424
  lappend options "c++"
419
425
  if { [string match "*-*-darwin*" $target_triplet] } {
426
+ if { [string match $compiler_vendor "gnu"] } {
427
+ lappend options "libs= -lc++"
428
+ }
429
+ } elseif { [string match "*android*" $target_triplet] } {
420
430
  lappend options "libs= -lc++"
421
431
  }
422
432
  }
@@ -430,6 +440,7 @@ proc libffi_target_compile { source dest type options } {
430
440
  # which causes it to be seen as unsupported.
431
441
  if { [string match "wasm32-*" $target_triplet] } {
432
442
  lappend options "additional_flags=-Wno-unused-command-line-argument"
443
+ lappend options "libs= -lpthread"
433
444
  }
434
445
 
435
446
  verbose "options: $options"
@@ -447,10 +458,12 @@ proc libffi_feature_test { test } {
447
458
  puts $f "#else"
448
459
  puts $f "# error Failed $test"
449
460
  puts $f "#endif"
461
+ puts $f "int main() {return 0;}"
450
462
  close $f
451
463
 
452
- set lines [libffi_target_compile $src /dev/null assembly ""]
464
+ set lines [libffi_target_compile $src $src.i preprocess ""]
453
465
  file delete $src
466
+ file delete $src.i
454
467
 
455
468
  return [string match "" $lines]
456
469
  }
@@ -463,10 +476,10 @@ proc libffi_feature_test { test } {
463
476
  proc search_for { file pattern } {
464
477
  set fd [open $file r]
465
478
  while { [gets $fd cur_line]>=0 } {
466
- if [string match "*$pattern*" $cur_line] then {
467
- close $fd
468
- return 1
469
- }
479
+ if [string match "*$pattern*" $cur_line] then {
480
+ close $fd
481
+ return 1
482
+ }
470
483
  }
471
484
  close $fd
472
485
  return 0
@@ -478,27 +491,27 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
478
491
  global runtests
479
492
 
480
493
  foreach test $testcases {
481
- # If we're only testing specific files and this isn't one of
482
- # them, skip it.
483
- if ![runtest_file_p $runtests $test] {
484
- continue
485
- }
486
-
487
- # Look for a loop within the source code - if we don't find one,
488
- # don't pass -funroll[-all]-loops.
489
- global torture_with_loops torture_without_loops
490
- if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
491
- set option_list $torture_with_loops
492
- } else {
493
- set option_list $torture_without_loops
494
- }
495
-
496
- set nshort [file tail [file dirname $test]]/[file tail $test]
497
-
498
- foreach flags $option_list {
499
- verbose "Testing $nshort, $flags" 1
500
- dg-test $test $flags ${default-extra-flags}
501
- }
494
+ # If we're only testing specific files and this isn't one of
495
+ # them, skip it.
496
+ if ![runtest_file_p $runtests $test] {
497
+ continue
498
+ }
499
+
500
+ # Look for a loop within the source code - if we don't find one,
501
+ # don't pass -funroll[-all]-loops.
502
+ global torture_with_loops torture_without_loops
503
+ if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
504
+ set option_list $torture_with_loops
505
+ } else {
506
+ set option_list $torture_without_loops
507
+ }
508
+
509
+ set nshort [file tail [file dirname $test]]/[file tail $test]
510
+
511
+ foreach flags $option_list {
512
+ verbose "Testing $nshort, $flags" 1
513
+ dg-test $test $flags ${default-extra-flags}
514
+ }
502
515
  }
503
516
  }
504
517
 
@@ -507,31 +520,31 @@ proc run-many-tests { testcases extra_flags } {
507
520
  global has_gccbug
508
521
  global env
509
522
  switch $compiler_vendor {
510
- "clang" {
511
- set common "-W -Wall"
512
- if [info exists env(LIBFFI_TEST_OPTIMIZATION)] {
513
- set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ]
514
- } else {
515
- set optimizations { "-O0" "-O2" }
523
+ "clang" {
524
+ set common "-W -Wall"
525
+ if [info exists env(LIBFFI_TEST_OPTIMIZATION)] {
526
+ set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ]
527
+ } else {
528
+ set optimizations { "-O0" "-O2" }
529
+ }
516
530
  }
517
- }
518
- "gnu" {
519
- set common "-W -Wall -Wno-psabi"
520
- if [info exists env(LIBFFI_TEST_OPTIMIZATION)] {
521
- set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ]
522
- } else {
523
- set optimizations { "-O0" "-O2" }
531
+ "gnu" {
532
+ set common "-W -Wall -Wno-psabi -fno-diagnostics-color"
533
+ if [info exists env(LIBFFI_TEST_OPTIMIZATION)] {
534
+ set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ]
535
+ } else {
536
+ set optimizations { "-O0" "-O2" }
537
+ }
524
538
  }
525
- }
526
- default {
527
- # Assume we are using the vendor compiler.
528
- set common ""
529
- if [info exists env(LIBFFI_TEST_OPTIMIZATION)] {
530
- set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ]
531
- } else {
532
- set optimizations { "" }
539
+ default {
540
+ # Assume we are using the vendor compiler.
541
+ set common ""
542
+ if [info exists env(LIBFFI_TEST_OPTIMIZATION)] {
543
+ set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ]
544
+ } else {
545
+ set optimizations { "" }
546
+ }
533
547
  }
534
- }
535
548
  }
536
549
 
537
550
  info exists env(LD_LIBRARY_PATH)
@@ -546,7 +559,7 @@ proc run-many-tests { testcases extra_flags } {
546
559
  "-DABI_NUM=FFI_FASTCALL -DABI_ATTR=__FASTCALL__"
547
560
  }
548
561
  } elseif { [istarget "x86_64-*-*"] \
549
- && [libffi_feature_test "#if !defined __ILP32__ \
562
+ && [libffi_feature_test "#if !defined __ILP32__ \
550
563
  && !defined __i386__"] } {
551
564
  set targetabis {
552
565
  ""
@@ -566,22 +579,22 @@ proc run-many-tests { testcases extra_flags } {
566
579
  foreach opt $optimizations {
567
580
  foreach abi $abis {
568
581
  set options [concat $common $opt $abi]
569
- set has_gccbug false;
570
- if { [string match $compiler_vendor "gnu"] \
571
- && [string match "*MSABI*" $abi] \
572
- && ( ( [string match "*DGTEST=57 *" $common] \
573
- && [string match "*call.c*" $testname] ) \
574
- || ( [string match "*DGTEST=54 *" $common] \
575
- && [string match "*callback*" $testname] ) \
576
- || [string match "*DGTEST=55 *" $common] \
577
- || [string match "*DGTEST=56 *" $common] ) } then {
578
- if [libffi_feature_test "#if (__GNUC__ < 9) || ((__GNUC__ == 9) && (__GNUC_MINOR__ < 3))"] {
579
- set has_gccbug true;
580
- }
581
- }
582
- verbose "Testing $testname, $options" 1
583
- verbose "has_gccbug = $has_gccbug" 1
584
- dg-test $test $options ""
582
+ set has_gccbug false;
583
+ if { [string match $compiler_vendor "gnu"] \
584
+ && [string match "*MSABI*" $abi] \
585
+ && ( ( [string match "*DGTEST=57 *" $common] \
586
+ && [string match "*call.c*" $testname] ) \
587
+ || ( [string match "*DGTEST=54 *" $common] \
588
+ && [string match "*callback*" $testname] ) \
589
+ || [string match "*DGTEST=55 *" $common] \
590
+ || [string match "*DGTEST=56 *" $common] ) } then {
591
+ if [libffi_feature_test "#if (__GNUC__ < 9) || ((__GNUC__ == 9) && (__GNUC_MINOR__ < 3))"] {
592
+ set has_gccbug true;
593
+ }
594
+ }
595
+ verbose "Testing $testname, $options" 1
596
+ verbose "has_gccbug = $has_gccbug" 1
597
+ dg-test $test $options ""
585
598
  }
586
599
  }
587
600
  }
@@ -593,8 +606,8 @@ proc dg-xfail-if { args } {
593
606
  set args [lreplace $args 0 0]
594
607
  set selector "target [join [lindex $args 1]]"
595
608
  if { [dg-process-target $selector] == "S" } {
596
- global compiler_conditional_xfail_data
597
- set compiler_conditional_xfail_data $args
609
+ global compiler_conditional_xfail_data
610
+ set compiler_conditional_xfail_data $args
598
611
  }
599
612
  }
600
613
 
@@ -606,22 +619,22 @@ proc check-flags { args } {
606
619
  # The next two arguments are optional. If they were not specified,
607
620
  # use the defaults.
608
621
  if { [llength $args] == 2 } {
609
- lappend $args [list "*"]
622
+ lappend $args [list "*"]
610
623
  }
611
624
  if { [llength $args] == 3 } {
612
- lappend $args [list ""]
625
+ lappend $args [list ""]
613
626
  }
614
627
 
615
628
  # If the option strings are the defaults, or the same as the
616
629
  # defaults, there is no need to call check_conditional_xfail to
617
630
  # compare them to the actual options.
618
631
  if { [string compare [lindex $args 2] "*"] == 0
619
- && [string compare [lindex $args 3] "" ] == 0 } {
620
- set result 1
632
+ && [string compare [lindex $args 3] "" ] == 0 } {
633
+ set result 1
621
634
  } else {
622
- # The target list might be an effective-target keyword, so replace
623
- # the original list with "*-*-*", since we already know it matches.
624
- set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
635
+ # The target list might be an effective-target keyword, so replace
636
+ # the original list with "*-*-*", since we already know it matches.
637
+ set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
625
638
  }
626
639
 
627
640
  return $result
@@ -637,7 +650,7 @@ proc dg-skip-if { args } {
637
650
  # Don't bother if we're already skipping the test.
638
651
  upvar dg-do-what dg-do-what
639
652
  if { [lindex ${dg-do-what} 1] == "N" } {
640
- return
653
+ return
641
654
  }
642
655
 
643
656
  set selector [list target [lindex $args 1]]
@@ -662,18 +675,18 @@ if { [info procs saved-dg-test] == [list] } {
662
675
  rename dg-test saved-dg-test
663
676
 
664
677
  proc dg-test { args } {
665
- global additional_files
666
- global additional_sources
667
- global errorInfo
668
-
669
- if { [ catch { eval saved-dg-test $args } errmsg ] } {
670
- set saved_info $errorInfo
671
- set additional_files ""
672
- set additional_sources ""
673
- error $errmsg $saved_info
674
- }
675
- set additional_files ""
676
- set additional_sources ""
678
+ global additional_files
679
+ global additional_sources
680
+ global errorInfo
681
+
682
+ if { [ catch { eval saved-dg-test $args } errmsg ] } {
683
+ set saved_info $errorInfo
684
+ set additional_files ""
685
+ set additional_sources ""
686
+ error $errmsg $saved_info
687
+ }
688
+ set additional_files ""
689
+ set additional_sources ""
677
690
  }
678
691
  }
679
692