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

Cannot build .asm files #16

Open
evilguest opened this issue Nov 5, 2020 · 8 comments
Open

Cannot build .asm files #16

evilguest opened this issue Nov 5, 2020 · 8 comments

Comments

@evilguest
Copy link

I have added a couple of .asm files to my VC++ project.
Visual Studio does build the project just fine; however, build via GCC fails with the following error message:

/home/runner/work/linq2d/linq2d/SauvolaBinarizeCPP/SauvolaBinarizeCPP.vcxproj(103,5): error MSB4019: The imported project "/home/runner/.nuget/packages/gccbuildtargets/1.19.325.5/build/BuildCustomizations/masm.props" was not found. Confirm that the expression in the Import declaration "/home/runner/.nuget/packages/gccbuildtargets/1.19.325.5/build//BuildCustomizations/masm.props" is correct, and that the file exists on disk.

See the
https://github.com/evilguest/linq2d/blob/master/SauvolaBinarizeCPP/SauvolaBinarizeCPP.vcxproj
for the project file detail.

Looks like we need a GCC-friendly counterpart of the masm.props and masm.targets.

@roozbehid
Copy link
Owner

Interesting.
Never taught asm files still have use cases :D
Yeah it needs support for them too which I havent done.

@evilguest
Copy link
Author

Do you have any idea on how to add the support for it? I know gcc is capable of building the asm; the question is how to feed those files to gcc.
I have tried to read the native masm.targets from my Visual Studio install. It is all gibberish to me: calls some custom MSBuild task.

@roozbehid
Copy link
Owner

I look into it.
You can help me by figuring out how we can feed them to gcc and all the required options.

@evilguest
Copy link
Author

Ok, working on it.
So far the obstacle is that GCC's as.exe doesn't like the MASM syntax. I have little to none experience with Win and Lin assemblers, so it would take some time

@roozbehid
Copy link
Owner

Oh so your format of assembly is also in MASM?
if GCC doesnt support it, I dont think we can.
Maybe a soltion can be MASM format for windows and some other compatible assembly format for gcc.

Dont worry about how feeding files into GCC. That is going to happen in my code.

@evilguest
Copy link
Author

I've read a bit on the subject. It seems that we have three options to support assembly files within the vcxproj across multiple platforms:

  1. Having different asm files for different platforms. This can cover Lin/Win differences as well as hardware, e.g. Arm/Intel. Contras:
  • extra work for the engineer contributing the code
  • hw differences are relevant for the target architecture, and should not restrict the build environment. I.e. it should be perfectly legal to build for ARM from Intel environment
  1. Auto-converstion from MASM to GAS via tools like intel2gas. Saves the coding effort. Contra:
  • Tough to predict the behavior and to troubleshoot. I.e. the code building fine on my laptop might fail (or produce incorrect results) when building under Ubuntu just because intel2gas doesn't do a good enough job.
  1. Switch over to NASM for the .asm compilation. This means we would have the same syntax across platforms, avoiding both the source file duplication and the dependency on a conversion tool.
    So far I am tempted to choose between 2 & 3, mostly towards 3. Will keep you posted on the progress.

@evilguest
Copy link
Author

Hi, I have finally managed to convert the .asm to NASM format and compile it within VS.
I am using the https://github.com/ShiftMediaProject/VSNASM project and it works like charm on Windows - my file is compiled by nasm and properly picked up by the VS2019 linker.
However, when I try to build via GCC, it fails miserably with a strange diag - no input files are fed into g++:
g++ -shared -m64 -o "/home/runner/work/linq2d/linq2d/SauvolaBinarizeCPP/x64/Release/SauvolaBinarizeCPP.so"
g++: fatal error: no input files [/home/runner/work/linq2d/linq2d/SauvolaBinarizeCPP/SauvolaBinarizeCPP.vcxproj]
The current state of the project is committed to https://github.com/evilguest/linq2d/tree/master/SauvolaBinarizeCPP.
I have triangulated this to the following code fragment in the .vcxproj file:

  <ItemGroup>
    <NASM Include="c4a2.asm">
      <FileType>Document</FileType>
    </NASM>
  </ItemGroup>

As soon as I remove it, gcc compiles everything like charm (but the project later fails to work since .so tries to resolve an unknown external in runtime).
Any advice would be much appreciated. So far I've tried to feed the files manually, but failed.

@evilguest
Copy link
Author

evilguest commented Nov 27, 2020

Have tried a few workarounds, including CustomBuildStep and PreLinkEvent. Neither do work when compiling with the GCC targets.

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

No branches or pull requests

2 participants