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

multilib: use cmodel=medany when multilib is enabled #58

Conversation

cfriedt
Copy link

@cfriedt cfriedt commented May 5, 2021

This change mitigates a number of linker errors due to unsupported
relocation types when multilib is enabled.

A typical error would be of the form:

relocation truncated to fit: R_RISCV_HI20 against `.LC0'

There are a number of similar issues filed, but that
example comes from riscv-collab/riscv-gnu-toolchain#784.

In particular, this change allowed me to build the Zephyr
RTOS for riscv on macos with CONFIG_NEWLIB_LIBC=y without any
such linker errors.

Fixes #57

This change mitigates a number of linker errors due to unsupported
relocation types when multilib is enabled.

A typical error would be of the form:

```
relocation truncated to fit: R_RISCV_HI20 against `.LC0'
```

There are a number of similar issues filed, but that
example comes from riscv-collab/riscv-gnu-toolchain#784.

In particular, this change allowed me to build the Zephyr
RTOS for riscv with `CONFIG_NEWLIB_LIBC=y` without any
such linker errors.

Fixes riscv-software-src#57

Signed-off-by: Christopher Friedt <[email protected]>
@aswaterman
Copy link
Contributor

Is the homebrew recipe really the right place for this? If this change is indeed appropriate (not saying it is--I think others might gripe), then I think it belongs in https://github.com/riscv/riscv-gnu-toolchain, since it's not specific to homebrew.

@sbeamer
Copy link
Collaborator

sbeamer commented May 18, 2021

@aswaterman any resolution on making this change elsewhere? Any harm in making it here?

@aswaterman
Copy link
Contributor

Well, I’m still not sure it is the right fix. Fundamentally, enabling multilibs and changing the default code model have nothing to do with each other. The only thing that should govern the choice of medlow (default) vs medany is the address at which code is linked.

I guess it’s reasonable to resolve this issue here, but decouple it from multilib (i.e. make the change unconditional). We might give up <1% perf on some compiled code, but the package will work for more people out of the box.

(Alternative is to expose the code model as an orthogonal option.)

aswaterman added a commit that referenced this pull request May 19, 2021
This does the right thing for more people's memory maps.

It will result in a very slight perf regression in programs heavy in
global variable access.  For application code, the old behavior can
be obtained by explicitly passing -mcmodel=medlow.

Supersedes #58
sbeamer pushed a commit that referenced this pull request May 22, 2021
This does the right thing for more people's memory maps.

It will result in a very slight perf regression in programs heavy in
global variable access.  For application code, the old behavior can
be obtained by explicitly passing -mcmodel=medlow.

Supersedes #58
@sbeamer
Copy link
Collaborator

sbeamer commented May 22, 2021

I merged #59 which should fix this. Thank you both for looking into this!

@sbeamer sbeamer closed this May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use cmodel=medany when multilib build is enabled
3 participants