Skip to content

Commit

Permalink
[rust] switch to -C debuginfo=2 (compiler-explorer#7266)
Browse files Browse the repository at this point in the history
This is mainly for `pahole`, which requires type information that is
only present with `-C debuginfo=2`:
https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo

CE originally passed `-g` to `rustc` (which is an alias for `-C
debuginfo=2`), but this was changed in
c4411ff to `-C debuginfo=1` to work
around rust-lang/rust#11906. However, this
workaround never actually removed frame pointers, so switching back to
`-C debuginfo=2` should not affect codegen for very old `rustc`
versions. See also compiler-explorer#79.
  • Loading branch information
narpfel authored and mattgodbolt committed Jan 30, 2025
1 parent a7bcabf commit 8b9a41b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/compilers/rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class RustCompiler extends BaseCompiler {
}

override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string, userOptions?: string[]) {
let options = ['-C', 'debuginfo=1', '-o', this.filename(outputFilename)];
let options = ['-C', 'debuginfo=2', '-o', this.filename(outputFilename)];

const userRequestedEmit = _.any(unwrap(userOptions), opt => opt.includes('--emit'));
if (filters.binary) {
Expand Down
4 changes: 2 additions & 2 deletions test/base-compiler-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ describe('Rust overrides', () => {
);
expect(originalOptions).toEqual([
'-C',
'debuginfo=1',
'debuginfo=2',
'-o',
'output.txt',
'--crate-type',
Expand All @@ -870,6 +870,6 @@ describe('Rust overrides', () => {
value: 'aarch64-linux-something',
},
]),
).toEqual(['-C', 'debuginfo=1', '-o', 'output.txt', '--crate-type', 'bin', '-Clinker=/usr/aarch64/bin/gcc']);
).toEqual(['-C', 'debuginfo=2', '-o', 'output.txt', '--crate-type', 'bin', '-Clinker=/usr/aarch64/bin/gcc']);
});
});

0 comments on commit 8b9a41b

Please sign in to comment.