This might actually be a ridiculous question, but there is so much about compilers/compiling that I don't understand. I'm aware of the concepts of cross compiling, cross-native compiling, etc. However, I am unaware of what applies for my scenario:
What I want to do is this.
Say I have two computers with different hardware, A and B.
Suppose that the only similarities between A and B I know for sure are:
- Both have some Intel processor capable of 64 bit computing.
- Both run Windows 10, and thus can access Linux through other means (e.g. WSL).
- Both A and B have all the programs necessary to compile (arbitrary) code.
Suppose that I also have administrative access to A (i.e. I can do/run/install whatever I want to/on it). This is not the case for B.
In addition, (this may be irrelevant), A can be accessed physically (and remotely if necessary). B can only be accessed remotely (via SSH, RDP, etc.)
Now say I want to compile some arbitrarily complex C/C++ code optimized specifically for the hardware on A with some compiler. For example, I believe -march=native
can achieve this if I use gcc
on A.
However, say A is special, and that its processing power cannot be "wasted" on compiling, for it has more important tasks to do. In other words, I do not want to go through the time and power consuming process of compilation on A.
Instead, I want to do this compilation for A on B.
How can I obtain an end result equivalent to a "-march=native"
compile done on A (if gcc
is used)? In other words, how can I compile code on B optimized precisely for the hardware on A?
For gcc
, is it as simple as finding the equivalent flags for -march=native
on A to then run execute on B? If so, is there a way to streamline this process and if not, how can it be done (if at all?).
Can the process be done with compilers other than gcc (namely, the Visual C++ and Intel C++ compilers)?