-
Notifications
You must be signed in to change notification settings - Fork 6
Single source-of-trust for build variables #102
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
Conversation
| get_serialised_cmake_env_vars(), | ||
| "cmake", | ||
| "-GNinja", | ||
| "-DFAASM_BUILD_TYPE={}".format(build_type), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already set by the toolchain file
0fd7c7e to
fe42914
Compare
…ned in python script
412a483 to
269216c
Compare
| } | ||
|
|
||
|
|
||
| def get_dict_as_cmake_vars(env_dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Faasm, we can pass the FAASM_RUNTIME_ENV_DICT variables as CMake CACHE variables, which is preferrable than env. variables. Unfortunately, CACHE variables are not always read/loaded properly in toolchain files so in faasm/cpp we revert to using env. variables.
Shillaker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice this looks good.
Re. the stand-alone CMake toolchain file, I had thought that it would be nice to template it from the Python code, rather than have it rely on env vars, but this is definitely not in scope atm.
In this PR I move all the variables needed to cross-compile C and C++ to WASM to a single Python file
faasmtools/build.py. All other files now read the values defined in this file. This change removes duplication of highly sensitive variables like the linker or compiler flags.I have decided to define all variables in a python file because we wrap calls to the compiler in python scripts anyway, which makes it easy to add the required variables.
The mechanism I have chosen to share variables between the python script and other files are environment variables. For example, a file like
WasiToolchain.cmakenow relies on a certain number of environment variables to be defined. Not having a self-contained*.cmakefile to include could make it less straight-forward to cross-compile a library outside offaasm/cpp, as you'd have to remember to prepend the env. vars before callingcmake, but works seamlessly in the scenario where we hold all the code to cross-compile libraries infaasm/cpp(as we have been doing withFFmpeg,ImageMagick, andTensorFlow, and I am planning to port LAMMPs and LULESH in the future as well).Another argument in favour of having all supported cross-compiled libraries in
faasm/cppis that this way it is easier to catch regressions, where a change in the toolchain breaks something that was building before. This, together with a minimal test in faasm/faasm, should ensure that we don't drop support to things we already support (even if the submodules rot away).In the process, I fix some formatting misalignments.
Closes #6