I'm working on an embedded project that will need to be maintainable for the next 25 years. This raises the interesting question of how this can be best supported. The obvious solution seems to be to use a VM that has a portable disk image that can be moved to any emulators in the future (the build environment is currently based around Ubuntu 14.04 LTS / x86_64) but how do you predict what vendors / hardware will be available in 25 years?
[emphasis mine]
maintainable for the next 25 years...use a VM
Some people are answering how to make something "compilable" 25 years in the future. That's different from making it "maintainable." A VM will make the project compilable. But it won't make it maintainable. Ex: I can compile MS COBOL code for CP/M, but I can't find developers to maintain it. The only way to make it maintainable is to continue to update to newer operating systems, libraries, and tools over the course of the 25 years. If you are in a regulated environment, there is cost to that. That cost needs to be part of the maintenance budget for years to come.
how do you predict what vendors / hardware will be available in 25 years?
That is impossible. If management wants you to do this, ask them what the budget will be in 25 years. You can accurately predict the development environment in 25 years with the same accuracy that they can predict the budget in 25 years. The closest you can get to this goal, is to have the source code for everything. When you use closed-source software, then your contracts should require that the source code be released to you when the product is no longer supported. Such conditions are not uncommon in the medical industry. The contract will likely forbid you from using that source code for anything other than maintaining that product since they won't want you become a competitor.
I work for a medical device manufacturer, who does this. We do *not* try to predict what tools will be available in the future. We keep VMs and make sure it doesn't require external packages to run. Ex: all installs, binaries, etc. are available. No npm or nuget required on the build server. Over the course of decades, you will have to move the source into newer repositories (RCS -> CVS -> subversion -> GIT) or keep ZIP file archives since that is easier.