e.g. I compiled Emacs to run on Redhat Linux. Since I wanted to compile it with --with-native-compilation flag, I had to install Redhat's developer tools to get libgccjit. These tools are installed in /opt/rh/devtoolset-10/root. An enable script is provided which modifies the LD_LIBRARY_PATH and PKG_CONFIG_PATH.
After compilation, I was able to launch Emacs from my bash terminal, but only after running the enable script (i.e. sets LD_LIBRARY_PATH to the correct directory). In a fresh terminal or after logging out and logging back in, launching Emacs gives the error:
emacs: error while loading shared libraries: libgccjit.so.0: cannot open shared object file: No such file or directory
Moreover, launching from application menu fails. I was able to get it to launch by modifying the binaries rpath, but then emacs gave lots of libgccjit.so errors afterword, when trying to lazy compile different internal applications: error invoking gcc driver.
I also tried compiling on Mac, but found myself experiencing a variety of issues that I didn't want to spend time thinking about. So I went with someone else's pre-built binaries.
brew tap d12frosted/emacs-plus
brew install emacs-plus@28 --with-native-compI use macports, and refuse to use brew (for a variety of philosophical reasons) so that option wasn't available to me. I often use the binary from https://emacsformacos.com/ but afaik it hadn't supported native compilation as yet. So I found some prebuilt binaries on github.