Some people don’t know, but Microchip uses GCC compiler on their MPLAB, they are using it for more than 15 years and never contributed back to mainline. Even worst: they have some non-free optimization that they don’t release as open-source. But don’t worry, Darwin is implacable, they are losing marketing share year after year (even after spent Billions to buy Atmel).

Now the good news is someone created some script to compile pic30-gcc to Linux (or Cygwin) with the patches that Microchip was obligated to release as open-source because the GPL license and put it here: https://github.com/makes/c30-linux but it is outdated for about 11 years.

Even so I decided to try to compile it and after some small modifications I succeeded, these are the steps:

$ git clone https://github.com/makes/c30-linux
$ cd c30-linux
$ git am /path/to/0001-Fix-pic30-linux-compilation-on-Ubuntu-21.10.patch
$ ./configure
$ make
$ sudo make install
$ sudo cp -a /usr/local/pic30/* /usr/local/

I don’t have plans to use it and I suggest you to avoid using it. It is better to use a microcontroller with a well supported GCC compiler from a company that contribute back to the open-source community.

Note: the above patch can be downloaded from here: https://pastebin.com/raw/9N7CiBYX