Skip to content

Commit 7cb3647

Browse files
committed
Merge pull request #704 from sodabrew/with_sanitize_gcc
Update --with-sanitize for compatibility with GCC Address Sanitizer too
2 parents abe6b36 + 02c8cc6 commit 7cb3647

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ matrix:
4040
- mysql2gem.example.com
4141
- rvm: 2.0.0
4242
env: DB=mysql57
43-
- rvm: 2.0.0
44-
env: DB=mysql
45-
os: osx
4643
- rvm: 2.0.0
4744
env: DB=mysql55
4845
os: osx

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ all sanitizers or fail if none are available. If a command-separated list of
6464
specific sanitizers is given, configure will fail unless they all are available.
6565
Note that the some sanitizers may incur a performance penalty, and the Address
6666
Sanitizer may require a runtime library.
67+
To see line numbers in backtraces, declare these environment variables
68+
(adjust the llvm-symbolizer path as needed for your system):
69+
70+
``` sh
71+
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4
72+
export ASAN_OPTIONS=symbolize=1
73+
```
6774

6875
### Linux and other Unixes
6976

ext/mysql2/extconf.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def asplode(lib)
115115
]
116116

117117
usable_flags = wishlist.select do |flag|
118-
try_link('int main() {return 0;}', "-Werror -Wunknown-warning-option #{flag}")
118+
try_link('int main() {return 0;}', "-Werror #{flag}")
119119
end
120120

121121
$CFLAGS << ' ' << usable_flags.join(' ')
@@ -127,12 +127,13 @@ def asplode(lib)
127127
when true
128128
# Try them all, turn on whatever we can
129129
enabled_sanitizers = %w(address cfi integer memory thread undefined).select do |s|
130-
try_link('int main() {return 0;}', "-Werror -Wunknown-warning-option -fsanitize=#{s}")
130+
try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
131131
end
132+
abort "-----\nCould not enable any sanitizers!\n-----" if enabled_sanitizers.empty?
132133
when String
133134
# Figure out which sanitizers are supported
134135
enabled_sanitizers, disabled_sanitizers = sanitizers.split(',').partition do |s|
135-
try_link('int main() {return 0;}', "-Werror -Wunknown-warning-option -fsanitize=#{s}")
136+
try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
136137
end
137138
end
138139

@@ -149,6 +150,8 @@ def asplode(lib)
149150
end
150151
$CFLAGS << " -fsanitize=#{s}"
151152
end
153+
# Options for line numbers in backtraces
154+
$CFLAGS << ' -g -fno-omit-frame-pointer'
152155
end
153156

154157
if RUBY_PLATFORM =~ /mswin|mingw/

0 commit comments

Comments
 (0)