1# Runtime Platform Abstraction Layer (PAL) 2 3The ExecuTorch _Platform Abstraction Layer_ (PAL) provides a way for execution 4environments to override operations like: 5- Getting the current time. 6- Printing a log statement. 7- Panicking the process/system. 8 9The PAL function declarations are in 10[`executorch/runtime/platform/platform.h`](https://github.com/pytorch/executorch/blob/main/runtime/platform/platform.h). 11 12## Overriding the default PAL 13 14The default PAL implementation is in 15[`executorch/runtime/platform/default/posix.cpp`](https://github.com/pytorch/executorch/blob/main/runtime/platform/default/posix.cpp). 16It uses `std::chrono::steady_clock` for the time, prints log messages to 17`stderr`, and makes other default assumptions. 18 19But, if they don't work for your system, you can override the default PAL by: 20- Including 21 [`executorch/runtime/platform/platform.h`](https://github.com/pytorch/executorch/blob/main/runtime/platform/platform.h) 22 in one of your application's `.c` or `.cpp` files. 23- Defining an implementation of one or more of the `et_pal_*()` functions. 24 25The default PAL functions are weak symbols, so providing your own strong-symbol 26definition can override them at link time. To ensure that your definitions take 27precedence, you may need to ensure that the strong definitions precede the weak 28definitions in the link order. 29 30## Minimal PAL 31 32If you run into build problems because your system doesn't support the functions 33called by `posix.cpp`, you can instead use the no-op minimal PAL at 34[`executorch/runtime/platform/default/minimal.cpp`](https://github.com/pytorch/executorch/blob/main/runtime/platform/default/minimal.cpp) 35by passing `-DEXECUTORCH_PAL_DEFAULT=minimal` to `cmake`. This will avoid 36calling `fprintf()`, `std::chrono::steady_clock`, and anything else that 37`posix.cpp` uses. But since the `minimal.cpp` `et_pal_*()` functions are no-ops, 38you will need to override all of them. 39