3

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:

  1. 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}
    
  2. Run the configure file you just modified: ./configure
  3. make clean
  4. make
  5. Go up a level to the lib directory: cd ..
  6. Remove the old build, if present: rm -rf build/pic16
  7. 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?

EchoLynx
  • 410
  • 5
  • 11
  • 2
    using the `-W` flag does NOT fix anything, it just hides the warnings. Why have libraries for different processors in the same directory? put them in different directories and reference the correct directories when compiling/linking your projects for specific PIC processors. -OR- give each library a name that includes the processor, then pass to the link statements the correct processor name, so it references the correct library. – user3629249 Oct 01 '16 at 18:07
  • @user3629249 I really don't want to hide warnings. To answer your question, I don't know for sure. This is how SDCC organizes their libraries. SDCC works on many different kinds of hardware, not just PICs. They have a separate directory for pic16 and pic14 libraries, which is nice. Maybe they didn't want to have a separate directory for all the different PICs? There are a _lot_ of them. Renaming is possible, but I really don't want to have to modify all the libraries every time a new version of sdcc comes out in addition to compiling them for each chip. – EchoLynx Oct 04 '16 at 17:53

0 Answers0