Skip to content
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

gollvm: "at most two relocations per offset are supported" error, during the generation of gen-sysinfo.go #42679

Closed
advancedwebdeveloper opened this issue Nov 17, 2020 · 12 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@thanm thanm added this to the gollvm milestone Nov 17, 2020
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 17, 2020
@thanm
Copy link
Contributor

thanm commented Nov 17, 2020

That link doesn't seem to work for me -- I get a page with just

{"count":11,"value":"Uri expired"}

@thanm
Copy link
Contributor

thanm commented Nov 17, 2020

It looks good to me -- clean build of llvm-goc, the standard libraries, units tests, and clean unit test run. What is the problem?

@advancedwebdeveloper
Copy link
Author

I thought that error disallows to build something for libgo.
What is the cause of that error?
Please elaborate

@advancedwebdeveloper
Copy link
Author

Hm: Clang 9 brought an error:
https://github.com/advancedwebdeveloper/clang_test_cpu_features/commit/dddfcdcde5debe06a08f6b38733b1552c8645bbd/checks/1415489311/logs
.

CMake Error at tools/gollvm/cmake/modules/AddGollvm.cmake:68 (message):
C compiler does not support -fsplit-stack
Call Stack (most recent call first):

@thanm
Copy link
Contributor

thanm commented Nov 18, 2020

Yes, this is an llvm-godumpspec problem. No, https://go.googlesource.com/gollvm/+/890acef7d115f5e3855f174aa102c5766809275a is not related, this problem has been around a lot longer than that.

llvm-godumpspec works by reading the DWARF from a C/C++ compiler generated object file, and it uses the LLVM dwarf reading library to do this.

Turns out I can reproduce the same problem ("error: at most two relocations per offset are supported") just with the existing llvm dwarf dump too. Example:

$ ninja llvm-dwarfdump
...
$ cat small.c
#include <sys/time.h>
struct timespec blah;
struct timeval bletch;
$ gcc -g3 -c small.c
$ ./bin/llvm-dwarf-dump small.o
error: At most two relocations per offset are supported
error: At most two relocations per offset are supported
error: At most two relocations per offset are supported
error: At most two relocations per offset are supported
error: At most two relocations per offset are supported
...
$

I spent a little while in the debugger looking at this. It looks like the problem is with the way the reader handles relocations. At this line here:

https://github.com/llvm/llvm-project/blob/0ec5baa1324d61e79bc21a1307ea52aa43a12352/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp#L1754

it seems to be making the assumption that there is going to be only one debug section of a given name in an object file, which is definitely not true when -g3 is in effect (you get multiple .debug_macro sections).

I'm not sure it's worth pursuing a fix in the LLVM dwarf reader for this. I'll send a CL to use "-g2" instead of "-g3" for the sysinfo.c compile, that should take care of the issue (we don't look at the DWARF macro info in any case).

@advancedwebdeveloper
Copy link
Author

USAGE: llvm-godumpspec [options]

OPTIONS:
--as-secure-log-file-name= - As secure log file name (initialized from AS_SECURE_LOG_FILE env variable)
--asm-macro-max-nesting-depth= - The maximum nesting depth allowed for assembly macros.
--color - Use colors in output (default=autodetect)
--debug-pass= - Print PassManager debugging information
=Disabled - disable debug output
=Arguments - print pass arguments to pass to 'opt'
=Structure - print pass structure before run()
=Executions - print pass name before it is executed
=Details - print pass details when it is executed
--disable-ondemand-mds-loading - Force disable the lazy-loading on-demand of metadata when loading bitcode for importing.
--disable-symbolication - Disable symbolizing crash backtraces.
--dwarf-extended-loc= - Disable emission of the extended flags in .loc directives.
=Default - Default for platform
=Enable - Enabled
=Disable - Disabled
--filter-print-funcs= - Only print IR for functions whose name match this for all print-[before|after][-all] and change reporter options
-h - Alias for --help
--help - Display available options (--help-hidden for more)
--help-hidden - Display all available options
--help-list - Display list of available options (--help-list-hidden for more)
--help-list-hidden - Display list of all available options
--import-constants-with-refs - Import constant global variables with references
--import-full-type-definitions - Import full type definitions for ThinLTO.
--info-output-file= - File to append -stats and -timer output to
--macrotmp= - Macros file for *.c file
--mark-data-regions - Mark code section jump table data regions.
--non-global-value-max-name-size= - Maximum size for the name of non-global values.
--object= - Object file for *.c file
--opt-bisect-limit= - Maximum optimization to perform
--output= - Output file to write.
--pass-remarks= - Enable optimization remarks from passes whose name match the given regular expression
--pass-remarks-analysis= - Enable optimization analysis remarks from passes whose name match the given regular expression
--pass-remarks-missed= - Enable missed optimization remarks from passes whose name match the given regular expression
--pointersize= - Size of a pointer in bytes for the target architecture of interest. Defaults to host pointer size.
--print-after= - Print IR after specified passes
--print-after-all - Print IR after each pass
--print-all-options - Print all option values after command line parsing
--print-before= - Print IR before specified passes
--print-before-all - Print IR before each pass
--print-module-scope - When printing IR for print-[before|after]{-all} and change reporters, always print a module IR
--print-options - Print non-default options after command line parsing
--print-summary-global-ids - Print the global id for each value when reading the module summary
--propagate-attrs - Propagate attributes in index
--remarks-section - Emit a section containing remark diagnostics metadata. By default, this is enabled for the following formats: yaml-strtab, bitstream.
--rng-seed= - Seed for the random number generator
--stats - Enable statistics output from program (available with Asserts)
--stats-json - Display statistics as json data
--time-passes - Time each pass, printing elapsed time for each on exit
--trace - Enable debug trace output.
--track-memory - Enable -time-passes memory tracking (this may be slow)
--use-dbg-addr - Use llvm.dbg.addr for all local variables
--verify-dom-info - Verify dominator info (time consuming)
--version - Display the version of this program
--x86-align-branch= - Specify types of branches to align (plus separated list of types):
jcc indicates conditional jumps
fused indicates fused conditional jumps
jmp indicates direct unconditional jumps
call indicates direct and indirect calls
ret indicates rets
indirect indicates indirect unconditional jumps
--x86-align-branch-boundary= - Control how the assembler should align branches with NOP. If the boundary's size is not 0, it should be a power of 2 and no less than 32. Branches will be aligned to prevent from being across or against the boundary of specified size. The default value 0 does not align branches.
--x86-asm-syntax= - Choose style of code to emit from X86 backend:
=att - Emit AT&T-style assembly
=intel - Emit Intel-style assembly
--x86-branches-within-32B-boundaries - Align selected instructions to mitigate negative performance impact of Intel's micro code update for errata skx102. May break assumptions about labels corresponding to particular instructions, and should be used with caution.
--x86-pad-for-align - Pad previous instructions to implement align directives
--x86-pad-for-branch-align - Pad previous instructions to implement branch alignment
--x86-pad-max-prefix-size= - Maximum number of prefixes to use for padding

I still think that I should enable tracing.
It would be of help for end-users for other reasons, as well.

@thanm
Copy link
Contributor

thanm commented Nov 18, 2020

I still think that I should enable tracing.

If you are talking about "--trace", I don't think that will be helpful. The trace output is very verbose, and includes a lot of detail that will just confuse users.

I am preparing a CL that should fix this (get rid of the warning altogether).

@gopherbot
Copy link

Change https://golang.org/cl/271037 mentions this issue: gollvm: get rid of spurious DWARF reader errors

@thanm
Copy link
Contributor

thanm commented Nov 18, 2020

OK, fix submitted. Closing out this issue now...

@thanm thanm closed this as completed Nov 18, 2020
@advancedwebdeveloper
Copy link
Author

OK, thanks.
Btw I am able to reproduce your simple example, on Ubuntu 20.10, via

$ llvm-dwarfdump small.o
. Hence the name of the executable - it is a bit different.

https://gist.github.com/advancedwebdeveloper/325f1aa01c86f12680263743343f6bd2 - this is what I am getting.

@golang golang locked and limited conversation to collaborators Nov 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants