Menu ▾ ▴

#4252 mcs51: since r17128, sdcc does not find mcs51.lib after make install

open
None
MCS51
5
2 hours ago
1 day ago
Matt Mower
No

Since [r17128] ([feature-requests:#327]), sdcc cannot link mcs51 programs after make install. With --model-large, sdcc searches share/sdcc/lib/large for the library, and make install places it in share/sdcc/lib/mcs51-large. The other models differ in the same way. The regression tests pass because they are linked with the library directory given by -L.

1: Sample code that reproduces the problem

int x;

int main (void)
{
  return x / 3;
}

2: Exact command used to run SDCC on this sample code

sdcc -mmcs51 bug.c

The compiler was configured with --prefix=/usr/local and only the mcs51 port, and installed with make install.

3: SDCC version tested

SDCC : mcs51 TD- 4.6.4 #0 (Linux)

The compiler is trunk r17193, built on Debian 13 (amd64) from a git-svn mirror, so the revision number is 0. The code that causes the fault is the same in r17196, which I did not build.

4: Observed and expected behaviour

The link fails, and sdcc exits with status 1. The linker reports that it cannot find the library mcs51, and then it reports every library symbol that the program uses as undefined.

?ASlink-Warning-Couldn't find library 'mcs51'

In bug.lk, share/sdcc/lib/small is the only library directory. make install created share/sdcc/lib/mcs51-small and no share/sdcc/lib/small. With -L /usr/local/share/sdcc/lib/mcs51-small, sdcc links the program.

The program should link without -L, as it does with SDCC 4.6.0.

5: Additional checks

src/SDCCmain.c builds the library directory from the model names in src/mcs51/main.c, and those names were not changed in r17128. In the patch below, each name has the prefix mcs51-, as in the stm8 library directory stm8-large. With the patch, sdcc links the sample without -L in the small, large, and large stack-auto models. I did not run the regression suite with the patch.

--- a/src/mcs51/main.c
+++ b/src/mcs51/main.c
@@ -970,10 +970,10 @@

 static const char * models[] =
 {

-  "small",  "small-xstack",  "small-stack-auto",  "small-xstack-auto",
-  "medium", "medium-xstack", "medium-stack-auto", "medium-xstack-auto",
-  "large",  "large-xstack",  "large-stack-auto",  "large-xstack-auto",
-  "huge",   "huge-xstack",   "huge-stack-auto",   "huge-xstack-auto",
+  "mcs51-small",  "mcs51-small-xstack",  "mcs51-small-stack-auto",  "mcs51-small-xstack-auto",
+  "mcs51-medium", "mcs51-medium-xstack", "mcs51-medium-stack-auto", "mcs51-medium-xstack-auto",
+  "mcs51-large",  "mcs51-large-xstack",  "mcs51-large-stack-auto",  "mcs51-large-xstack-auto",
+  "mcs51-huge",   "mcs51-huge-xstack",   "mcs51-huge-stack-auto",   "mcs51-huge-xstack-auto",
 };

 static const char *

Related

Commit: [r17128]
Feature Requests: #327

Discussion

  • Matt Mower

    Matt Mower - 13 hours ago

    While testing the patch I found four more places that still use the mcs51
    library layout from before r17128. Checked against r17200.

    1. device/lib/Makefile.in, install rule: the last command is
      find $(sdcc_libdir)/src/mcs51 .... Since r17128 the rule copies
      mcs51-small, mcs51-medium, mcs51-large, and mcs51-huge to lib/src and
      does not create lib/src/mcs51, so I expect this find to fail. I read
      this from the rule and did not run an install with all ports enabled.

    2. The same rule does not copy device/lib/mcs51-common to lib/src, so the
      installed mcs51 library sources are incomplete. After make install,
      lib/src has the four mcs51-<model> directories and not mcs51-common.</model>

    3. support/scripts/sdcc.nsi still packages lib\small, lib\large,
      lib\small-stack-auto, lib\large-stack-auto, and lib\src\mcs51. I did
      not build the Windows installer.

    4. doc/sdccman.lyx still gives libsdcc.lib in <installdir>/share/lib/small
      as its example of a library file.</installdir>

    I can open separate tickets for these if you prefer.

     
  • Gabriele Gorla

    Gabriele Gorla - 2 hours ago
    • assigned_to: Gabriele Gorla
    • Category: other --> MCS51
     
  • Gabriele Gorla

    Gabriele Gorla - 2 hours ago

    patch applied to [r17202]
    I am looking at the other issues.

     
    ❤️
    1

    Related

    Commit: [r17202]


Log in to post a comment.