I want to compile a C ++ program for intermediate code. Then I want to compile the intermediate code for the current processor with all its resources.
The first step is to compile the C ++ program with optimization (-O2), start the linker and execute most of the compilation procedure. This step should be independent of the operating system and architecture.
The second step is to compile the result of the first step without source code for the operating system and processor of the current computer with optimization and special instructions from the processor (-march = native). The second step should be quick and with minimal software requirements.
Can I do it? How to do it?
Edit :
I want to do this because I want to distribute a platform-independent program that can use all processor resources without source code, instead of distributing compilation for each platform and operating system. It would be nice if the second step was quick and easy.
Processors of the same architecture can have different functions. X86 processors can have SSE1, SSE2, or others, and they can be 32 or 64 bits. If I compile for a generic X86, it will not have SSE optimization. After many years, processors will have new features, and the program must be compiled for new processors.
source
share