-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Emit error when trying to use assembler syntax directives in asm!
#82270
Merged
bors
merged 4 commits into
rust-lang:master
from
asquared31415:asm-syntax-directive-errors
Mar 18, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
12c6a12
Emit error when trying to use assembler syntax directives in `asm!`
asquared31415 39dcd01
Take into account target default syntax
asquared31415 05ae666
Move default inline asm dialect to Session
asquared31415 4b13b81
Test x86 and arm outputs
asquared31415 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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues | ||
--> $DIR/inline-syntax.rs:22:15 | ||
| | ||
LL | asm!(".att_syntax noprefix", "nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive | ||
|
||
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues | ||
--> $DIR/inline-syntax.rs:25:15 | ||
| | ||
LL | asm!(".att_syntax bbb noprefix", "nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive | ||
|
||
error: aborting due to 2 previous errors | ||
|
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// revisions: x86_64 arm | ||
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu | ||
//[arm] compile-flags: --target armv7-unknown-linux-gnueabihf | ||
|
||
#![feature(no_core, lang_items, rustc_attrs)] | ||
#![no_core] | ||
|
||
#[rustc_builtin_macro] | ||
macro_rules! asm { | ||
() => {}; | ||
} | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
fn main() { | ||
unsafe { | ||
asm!(".intel_syntax noprefix", "nop"); | ||
//[x86_64]~^ ERROR intel syntax is the default syntax on this target | ||
asm!(".intel_syntax aaa noprefix", "nop"); | ||
//[x86_64]~^ ERROR intel syntax is the default syntax on this target | ||
asm!(".att_syntax noprefix", "nop"); | ||
//[x86_64]~^ ERROR using the .att_syntax directive may cause issues | ||
//[arm]~^^ att syntax is the default syntax on this target | ||
asm!(".att_syntax bbb noprefix", "nop"); | ||
//[x86_64]~^ ERROR using the .att_syntax directive may cause issues | ||
//[arm]~^^ att syntax is the default syntax on this target | ||
asm!(".intel_syntax noprefix; nop"); | ||
//[x86_64]~^ ERROR intel syntax is the default syntax on this target | ||
|
||
asm!( | ||
r" | ||
.intel_syntax noprefix | ||
nop" | ||
); | ||
//[x86_64]~^^^ ERROR intel syntax is the default syntax on this target | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues | ||
--> $DIR/inline-syntax.rs:18:15 | ||
| | ||
LL | asm!(".intel_syntax noprefix", "nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive | ||
|
||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues | ||
--> $DIR/inline-syntax.rs:20:15 | ||
| | ||
LL | asm!(".intel_syntax aaa noprefix", "nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive | ||
|
||
error: using the .att_syntax directive may cause issues, use the att_syntax option instead | ||
--> $DIR/inline-syntax.rs:22:15 | ||
| | ||
LL | asm!(".att_syntax noprefix", "nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: remove the assembler directive and replace it with options(att_syntax) | ||
| | ||
LL | asm!("", "nop", options(att_syntax)); | ||
| -- ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: using the .att_syntax directive may cause issues, use the att_syntax option instead | ||
--> $DIR/inline-syntax.rs:25:15 | ||
| | ||
LL | asm!(".att_syntax bbb noprefix", "nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: remove the assembler directive and replace it with options(att_syntax) | ||
| | ||
LL | asm!("", "nop", options(att_syntax)); | ||
| -- ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues | ||
--> $DIR/inline-syntax.rs:28:15 | ||
| | ||
LL | asm!(".intel_syntax noprefix; nop"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive | ||
|
||
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues | ||
--> $DIR/inline-syntax.rs:33:14 | ||
| | ||
LL | .intel_syntax noprefix | ||
| ______________^ | ||
LL | | nop" | ||
| |_ help: remove this assembler directive | ||
|
||
error: aborting due to 6 previous errors | ||
|
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.
The concept of an asm dialect doesn't exist outside of x86. In fact the
.att_syntax
and.intel_syntax
directives are x86-specific and don't exist on other targets.