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

fix: asm() using incorrect assembler for amd64 architecture #2510

Closed
wants to merge 1 commit into from

Conversation

CuB3y0nd
Copy link

I cannot find something like i386-elf-as, such as x86_64-elf-as, but amd64 should just use as for the default assembler. This could fix #2509.

@Arusekk
Copy link
Member

Arusekk commented Jan 7, 2025

Thanks for the fix! Although it might work for you, I have some feedback.

x:x mapping is already considered, so this change is wrong (better drop i386 if so). There are some systems where i386-*-as speaks amd64 as well as x86. The thing is as should be tried before it, because there might be some broken setup. Please try to adjust the search logic to consider the ordering.

Does your system have *86*64*-*-as anywhere in PATH (there are many places)? If I understand correctly, it does it have as but no native as with explicit name; I had no idea this was possible, please check this, as it seems very unlikely.

@Arusekk
Copy link
Member

Arusekk commented Jan 7, 2025

(Note that some people have a different host arch, like arm or riscv. Please do not assume that as is good for any particular arch by itself.)

@CuB3y0nd
Copy link
Author

CuB3y0nd commented Jan 7, 2025

Thanks for the fix! Although it might work for you, I have some feedback.

x:x mapping is already considered, so this change is wrong (better drop i386 if so). There are some systems where i386-*-as speaks amd64 as well as x86. The thing is as should be tried before it, because there might be some broken setup. Please try to adjust the search logic to consider the ordering.

Does your system have *86*64*-*-as anywhere in PATH (there are many places)? If I understand correctly, it does it have as but no native as with explicit name; I had no idea this was possible, please check this, as it seems very unlikely.

I found that Arch Linux does not provide *86*64*-*-as by default, but instead provides host architecture support via as. I had to manually install x86_64-elf-binutils and x86_64-elf-gcc via yay to get *86*64*-*-as. So i think this problem should not be solved by prioritizing *86*64*-*-as, if Arch Linux does not detect *86*64*-*-as, as should be used by default to provide amd64 support.

Or one could also assume that this problem is a matter of me not having the appropriate tools installed, maybe?

@Arusekk
Copy link
Member

Arusekk commented Mar 1, 2025

Your setup is correct. I assume you got this stripped i386-elf-as from AUR, honestly it does not look like something present on any other distro out there, but you have it so someone else might have it as well.

Nevertheless, the correct solution should be:

  • always try explicit binutils with the first alias (here: *86*64*-*-as)
  • next (if explicit absent), try native (only if target == native) (here: as),
  • next (if explicit absent and if native absent or irrelevant), try other aliases (here: i*86*-*-as).

(Current behaviour is try explicit, then try aliases and only then try native. It is broken, as demonstrated by your case. The above algorithm should fix it.)

@Arusekk Arusekk linked an issue Mar 1, 2025 that may be closed by this pull request
@CuB3y0nd CuB3y0nd closed this by deleting the head repository Mar 1, 2025
@CuB3y0nd
Copy link
Author

CuB3y0nd commented Mar 1, 2025

Your setup is correct. I assume you got this stripped i386-elf-as from AUR, honestly it does not look like something present on any other distro out there, but you have it so someone else might have it as well.

Nevertheless, the correct solution should be:

* always try explicit binutils with the first alias (here: `*86*64*-*-as`)

* next (if explicit absent), try native (only if target == native) (here: `as`),

* next (if explicit absent and if native absent or irrelevant), try other aliases (here: `i*86*-*-as`).

(Current behaviour is try explicit, then try aliases and only then try native. It is broken, as demonstrated by your case. The above algorithm should fix it.)

Applied this solution in #2558

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.

asm() using the incorrect assembler for amd64 architecture amd64 considered native architecture on i386
2 participants