-
Notifications
You must be signed in to change notification settings - Fork 3
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
NH-89406: improve control for building debug version of the extension and added documentation #155
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ed300aa
NH-89406: remove debug flag for release version of apm
xuan-cao-swi b2c1766
fix markdown lint
xuan-cao-swi 2e8f245
Update ext/oboe_metal/extconf.rb
xuan-cao-swi 0cfb885
Update ext/oboe_metal/README.md
xuan-cao-swi 93069f4
Update ext/oboe_metal/README.md
xuan-cao-swi 4465b0f
revision
xuan-cao-swi 42fb9da
Merge branch 'NH-89406' of github.com:solarwinds/apm-ruby into NH-89406
xuan-cao-swi caee4fc
partial revision
xuan-cao-swi 368c0ef
partial revision
xuan-cao-swi ddf8d63
Merge branch 'main' into NH-89406
xuan-cao-swi 3ce3721
NH-89406: add relwithdebinfo source
xuan-cao-swi d271223
NH-89406: add test case for mkmf
xuan-cao-swi dc5be3d
lint
xuan-cao-swi 5936fb4
fix the alpine lib issue
xuan-cao-swi 7ad97e8
change to prod debug build
xuan-cao-swi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ test/clib/Makefile | |
*.so | ||
*.o | ||
ext/oboe_metal/extconf_local.rb | ||
Makefile | ||
|
||
# test script | ||
install_gem.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,22 +18,25 @@ | |
init_mkmf(CONFIG) | ||
|
||
ext_dir = __dir__ | ||
oboe_debug = ENV['OBOE_DEBUG'].to_s.casecmp('true').zero? | ||
non_production = ENV['OBOE_DEV'].to_s.casecmp('true').zero? || ENV['OBOE_STAGING'].to_s.casecmp('true').zero? | ||
|
||
# Set the mkmf lib paths so we have no issues linking to | ||
# the SolarWindsAPM libs. | ||
swo_lib_dir = File.join(ext_dir, 'lib') | ||
swo_include = File.join(ext_dir, 'src') | ||
version = File.read(File.join(ext_dir, 'src', 'VERSION')).strip | ||
|
||
# Download the appropriate liboboe from Staging or Production | ||
version = File.read(File.join(swo_include, 'VERSION')).strip | ||
if ENV['OBOE_DEV'].to_s.casecmp('true').zero? | ||
# OBOE_DEBUG has the highest priorities over oboe environment | ||
if oboe_debug | ||
swo_path = File.join('https://agent-binaries.cloud.solarwinds.com/apm/c-lib/', version, 'relwithdebinfo') | ||
puts 'Fetching c-lib from PRODUCTION DEBUG Build' | ||
elsif ENV['OBOE_DEV'].to_s.casecmp('true').zero? | ||
swo_path = 'https://solarwinds-apm-staging.s3.us-west-2.amazonaws.com/apm/c-lib/nightly' | ||
puts 'Fetching c-lib from DEVELOPMENT Build' | ||
elsif ENV['OBOE_STAGING'].to_s.casecmp('true').zero? | ||
swo_path = File.join('https://agent-binaries.global.st-ssp.solarwinds.com/apm/c-lib/', version) | ||
puts 'Fetching c-lib from STAGING' | ||
puts 'Fetching c-lib from STAGING Build' | ||
else | ||
swo_path = File.join('https://agent-binaries.cloud.solarwinds.com/apm/c-lib/', version) | ||
puts 'Fetching c-lib from PRODUCTION Build' | ||
end | ||
|
||
swo_arch = 'x86_64' | ||
|
@@ -70,23 +73,27 @@ | |
begin | ||
IO.copy_stream(URI.parse(swo_item).open, clib) | ||
clib_checksum = Digest::SHA256.file(clib).hexdigest | ||
checksum = File.read(swo_checksum_file).strip | ||
checksum = File.read(swo_checksum_file).strip | ||
|
||
# sha256 always from prod, so no matching for stg or nightly build or debug mode | ||
# so ignore the sha comparsion when fetching from development and staging build | ||
checksum = clib_checksum if non_production || oboe_debug | ||
|
||
# unfortunately these messages only show if the install command is run | ||
# with the `--verbose` flag | ||
if clib_checksum == checksum | ||
success = true | ||
retries = 0 | ||
else | ||
puts 'Checksum Verification Fail' # this is mainly for testing | ||
warn '== ERROR =================================================================' | ||
warn 'Checksum Verification failed for the c-extension of the solarwinds_apm gem' | ||
warn 'Installation cannot continue' | ||
warn "\nChecksum packaged with gem: #{checksum}" | ||
warn "Checksum calculated from lib: #{clib_checksum}" | ||
warn 'Contact [email protected] if the problem persists' | ||
warn '==========================================================================' | ||
exit 1 | ||
end | ||
retries = 0 | ||
rescue StandardError => e | ||
File.write(clib, '') | ||
retries -= 1 | ||
|
@@ -118,22 +125,26 @@ | |
$libs = append_library($libs, 'stdc++') | ||
|
||
$CFLAGS << " #{ENV.fetch('CFLAGS', nil)}" | ||
# $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11" | ||
# TODO for debugging: -pg -gdwarf-2, remove for production | ||
# -pg does not work on alpine https://www.openwall.com/lists/musl/2014/11/05/2 | ||
$CPPFLAGS << " #{ENV.fetch('CPPFLAGS', nil)} -std=c++11 -gdwarf-2 -I$$ORIGIN/../ext/oboe_metal/include -I$$ORIGIN/../ext/oboe_metal/src" | ||
# $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -I$$ORIGIN/../ext/oboe_metal/include" | ||
|
||
# -pg option is used for generating profiling information with gprof | ||
cheempz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$CPPFLAGS << if oboe_debug | ||
" #{ENV.fetch('CPPFLAGS', nil)} -std=c++11 -gdwarf-2 -I$$ORIGIN/../ext/oboe_metal/src" | ||
else | ||
" #{ENV.fetch('CPPFLAGS', nil)} -std=c++11 -I$$ORIGIN/../ext/oboe_metal/src" | ||
end | ||
|
||
$LIBS << " #{ENV.fetch('LIBS', nil)}" | ||
|
||
# use "z,defs" to see what happens during linking | ||
# $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib,-z,defs' -lrt" | ||
# -lrt option is used when linking programs with the GNU Compiler Collection (GCC) to | ||
# include the POSIX real-time extensions library, librt. | ||
$LDFLAGS << " #{ENV.fetch('LDFLAGS', nil)} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib' -lrt" | ||
$CXXFLAGS += ' -std=c++11 ' | ||
|
||
# ____ include debug info, comment out when not debugging | ||
# ____ -pg -> profiling info for gprof | ||
CONFIG['debugflags'] = '-ggdb3 ' | ||
CONFIG['optflags'] = '-O0' | ||
# OBOE_DEBUG need to be enabled before downloading and installing the gem | ||
cheempz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if oboe_debug | ||
CONFIG['debugflags'] = '-ggdb3 ' | ||
CONFIG['optflags'] = '-O0' | ||
end | ||
|
||
create_makefile('libsolarwinds_apm', 'src') | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice DRYing :)