meson: Underscore prefix detection broken if -g specified

This is not an issue currently, due to #5481 hiding this bug but once that is solved, it will become an issue again.

If the cflags contain -g, the test for the underscore symbol would incorrectly return as soon as it finds the symbol with or without underscore, but when debug symbols are enabled using -g, this will yield the false result. This can easily be illustrated by a small testcase:

symbol_name = b'meson_uscore_prefix'
with open('out.obj', 'rb') as o:
    for line in o:
        # Check if the underscore form of the symbol is somewhere
        # in the output file.
        if b'_' + symbol_name in line:
            print('True')
        # Else, check if the non-underscored form is present
        elif symbol_name in line:
            print('False')

Would print:

False
True

as it first finds the symbol without the underscore, only later finds the symbol with underscore.

Of course this is not an issue when using the meson buildtype option, as meson will not use the -g argument from that for the test, but is an issue when -g is contained in externally provided flags by env variables or crossfile.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@nirbheek Doing that is really tricky given the amount of platforms meson already supports, but I found a much better solution, will submit the PR for this probably tomorrow evening.