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

Compilation issues with non-standard C keywords and functions. #489

Open
ShubhamGupta577 opened this issue Sep 16, 2024 · 3 comments
Open

Comments

@ShubhamGupta577
Copy link

I'm working on compiling an existing codebase using the WASI-SDK24 which is more of a legacy code written long way back for older compilers, but I'm encountering compilation errors due to the use of non-standard C keywords and functions in the codebase. I would greatly appreciate any guidance or assistance from the community in resolving this issue.

Background:

  • The codebase is written in C and has been in development for several years.
  • It includes some non-standard keywords and functions that were likely used for platform-specific or legacy reasons.
  • I'm attempting to compile this codebase using the WASI-SDK 24 on Linux(Ubuntu) x86.

Errors encountered:-

  • expected ';' after top level declarator
typedef unsigned long huge *  UNSIGNED PTR;
typedef void __interrupt COMISR();
  • variable has incomplete type 'void'
void _Cdecl _FARFUNC __assertfail( CONST char _FAR *__msg, ..)

There are multiple errors similar to this and these are mainly due to the keywords like "huge, far, _FARFUNC" and the functions like __interrupt which are of non c standard.

So if there is any solution in which wasi-sdk provide the support to run old code will be useful.

@sunfishcode
Copy link
Member

If you want the compiler to ignore those keywords, you could try passing -Dhuge= -D_FARFUNC= -Dfar= -D__interrupt= to the compiler.

Wasm doesn't have any kind of interrupt handler functionality, so if the function with __interrupt is expected to be called on interrupts, you'll likely need to change the code in some way.

@ShubhamGupta577
Copy link
Author

ShubhamGupta577 commented Sep 17, 2024

Thanks for you help.
I tried to implement the solution but this solution is ignoring the keywords which mentioned in the flags due to that there is some functionality breakdown in code base

I have a old code base which was build on the 'Paradigm C++ Compiler" which supports the non standard keywords and functions, now I want to convert that into wasm using the wasi-sdk so that I can reduce the memory footprint.
So is there any way I can do this without breaking the existing functionality.
Reference link of Paradigm C++:- https://www.embeddedindia.com/paradigm-software.html

In my understanding the issue is that wasi-sdk is using the clang which doesn't support the non standard keywords.

@sbc100
Copy link
Member

sbc100 commented Sep 17, 2024

If the code in question can't be compiled with clang, then its highly unlikely you will be able to compile it with wasi-sdk, which simply used an unmodified version of upstream clang.

If you would like to pursue those features in clang then you might want to ask upstream in the clang project if there is any interest in adding them, but WASI and wasi-sdk probably isn't the right venue to propose this.

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

3 participants