I have a C project for a PIC that I am building with SDCC 3.6.3 and gputils 1.5.0, both of which I built from source.
When linking my project, I get the following error messages from gplink:
warning: Processor mismatch in "streams.o".
warning: Processor mismatch in "mullong.o".
warning: Processor mismatch in "divulong.o".
warning: Processor mismatch in "gptrput1.o".
warning: Processor mismatch in "divuint.o".
warning: Processor mismatch in "gptrget1.o".
warning: Processor mismatch in "eeprom16_gptrget1_dispatch.o".
warning: Processor mismatch in "eeprom16_gptrput1_dispatch.o".
warning: Processor mismatch in "eeprom16_gptrput1.o".
warning: Processor mismatch in "eeprom16_gptrget1.o".
warning: Processor mismatch in "eeprom16_write.o".
There is a specific flag to silence these warnings (-w) but I don't like any warnings when my projects are being built. Some searching led me to a short conversation from 2007 that addressed this issue: the libraries included with SDCC will be built for a PIC 18f452 by default. My project uses an 18f26k22, causing these warnings.
The above conversation included instructions on how to rebuild the pic16 libraries for a different target. They were out of date, but I figured it out by reading the configure script. I followed these steps to recompile the libraries:
Modify the file
device/lib/pic16/configure
. Notice that you can also specify the ARCH environment variable at the shell like the above link described. (ARCH=18f26k22 make
)# The default architecture can be selected at configure time by setting the # environment variable ARCH to the desired device (18fxxx). ARCH=${ARCH:-18f452}
- Run the configure file you just modified:
./configure
make clean
make
- Go up a level to the lib directory:
cd ..
- Remove the old build, if present:
rm -rf build/pic16
make
You may need to repeat this for the non-free code, if you use it. It lives in device/non-free/lib/pic16
.
Once you have it built, you can change gplink parameters so that the -I flags point to the build directories in containing the libraries you just built. Ex: -I/home/username/sdcc/device/lib/build/pic16 -I/home/username/sdcc/device/non-free/lib/build/pic16
Unfortunately, gplink uses the first lib that it finds. This means that you can't build the libs for every pic you use, keep them all in different paths, and have a -I path to each of them. gplink will pick the first one and use that, even if there are other versions in other -I paths that don't produce a processor mismatch error.
Furthermore, running make install
to copy the libs built for a particular chip into /usr/local/sdcc doesn't help if you develop for more than one chip.
Is there a cleaner way of handling this other than including a custom built copy of everything that my project requires or using the -w flag?