IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Compilation croisée avec GCC 4 sous Windows pour Linux

Compilation croisée avec GCC 4 sous Windows pour Linux


précédentsommairesuivant

III. Compilation des binutils

III-A. Problème de BFD

III-A-1. Symptômes

La compilation plante avec des messages du genre :

 
Sélectionnez
checking for 8-bit support... no
checking for 16-bit support... no
checking for 32-bit support... no
checking for 64-bit support... no

Ou bien :

 
Sélectionnez
checking for time.h... no
checking for sys/time.h... no
checking for sys/types.h... no
checking for sys/sysmp.h... no
checking for sys/sysinfo.h... no
checking for machine/hal_sysinfo.h... no

Ou bien des messages semblables.

En général, le premier type de problème apparaît après le second type de problème.

III-A-2. Le pourquoi

Attention !
Ceci n'est que pures spéculations, vu que la mailing-list n'a pas su résoudre le problème d'une autre manière que celle décrite plus bas.

Apparemment, la nouvelle version de GCC n'est pas complètement compatible avec cette version de MSYS, lorsque MSYS a été utilisé pour la compilation.

En fait, GCC (nouvellement compilé) ne va pas chercher les bons includes (ceux de l'ancienne version), ou ne les trouve pas du tout, en fonction du cas. Ce qui finit avec de graves problèmes au niveau des types : si les binutils arrivent à se passer des includes standards, ils ont quand même besoin d'une partie des mathématiques incluses, qui sont introuvables.

Cependant, ce dysfonctionnement ne perturbe en rien le fonctionnement du compilateur hors-MSYS.

III-A-3. La résolution du problème

La résolution est triviale : prévoyez l'utilisation de l'ancien compilateur.
Pour ce faire, dans le fstab, remplacez les références au nouveau compilateur par celles de l'ancien.

III-B. Cette application n'a pas pu démarrer car libiconv-2.dll est introuvable

III-B-1. Symptômes

Il se peut que, lors de la configuration, des applications ne trouvent pas libiconv-2.dll, car elles sont liées à cette DLL, et seule la libiconv2.dll est disponible.

III-B-2. Résolution

Dans le répertoire de MSYS, copiez le fichier libiconv2.dll en libiconv-2.dll.
Arrêtez la compilation (plusieurs Ctrl+Z, un seul ne faisant pas effet immédiat), puis relancez-la.
Sinon, des programmes seront compilés sans support de ces exécutables, qui apportent de très importantes fonctionnalités (la gestion des messages), notamment.

IV. Compilation de GCC

Si vous devez modifier un fichier avec la moindre de ces procédures, n'oubliez surtout pas de faire un grand nettoyage avec make clean dans le dossier si des erreurs qui ne sont pas précisées ici apparaissent !

De nombreuses solutions apportées ici prennent leur essence dans des bugs dans la fonction free. Leur correction apporte généralement son lot de fuites de mémoires, mais uniquement du côté compilateur, pas programmes compilés.

IV-A. _error_not_here_yet - havent even thought about it - it may even work

IV-A-1. Symptômes

Ce message apparaît lors de la compilation, juste avant la compilation de GNAT : (sic !)

 
Sélectionnez
_error_not_here_yet - havent even thought about it - it may even work
/bin/sh: _error_not_here_yet: command not found

Serait-ce un easter egg ? Toujours est-il que cette erreur empêche la compilation ...

IV-A-2. Résolution

Créez, dans /msys/bin, un fichier _error_not_here_yet vide.

IV-B. fenv.h: No such file or directory

IV-B-1. Symptômes

Les messages suivants apparaissent :

 
Sélectionnez
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:52:18: error: fenv.h: No such file or directory
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c: In function '__dfp_test_except':
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:64: error: 
'FE_INEXACT' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:64: error: 
(Each undeclared identifier is reported only once
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:64: error: 
for each function it appears in.)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:66: error: 
'FE_UNDERFLOW' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:68: error: 
'FE_OVERFLOW' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:70: error: 
'FE_DIVBYZERO' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:72: error: 
'FE_INVALID' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c: In function '__dfp_raise_except':
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:81: error: 
'FE_INEXACT' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:83: error: 
'FE_UNDERFLOW' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:85: error: 
'FE_OVERFLOW' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:87: error: 
'FE_DIVBYZERO' undeclared (first use in this function)
../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:89: error: 
'FE_INVALID' undeclared (first use in this function

Uniquement lorsque vous êtes obligés d'utiliser une version 3 de GCC.

IV-B-2. Résolution

Copiez le fichier fenv.h qui se trouve, normalement, dans un des chemins suivants :

  • /gcc/include
  • /gcc/include/c++/4.3.2

Respectivement, dans tous les répertoires suivants :

  • /mingw/include
  • /mingw/include/c++/3.4.5

Si cela ne fonctionne pas, copiez le fichier fenv.h (le plus lourd), dans le répertoire /work/src/gcc/libgcc/config/libbid

Si ce genre d'erreurs apparaît ensuite :

 
Sélectionnez
In file included from ../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:52:
../../../../src/gcc/libgcc/config/libbid/fenv.h:4:20: error: _mingw.h: No such file or directory
In file included from ../../../../src/gcc/libgcc/config/libbid/bid_decimal_globals.c:52:
../../../../src/gcc/libgcc/config/libbid/fenv.h:84: error:
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:85: error:
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:86: error:
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:87: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:88: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:92: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:93: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:97: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:98: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:99: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'
../../../../src/gcc/libgcc/config/libbid/fenv.h:100: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before '__MINGW_NOTHROW'

Copiez le fichier /gcc/include/_mingw.h dans ce même dossier.

IV-C. pthread.h: No such file or directory

IV-C-1. Symptômes

Les messages suivants apparaissent :

 
Sélectionnez
In file included from ../.././gcc/gthr-default.h:1,
                 from ../../../../src/gcc/libgcc/../gcc/gthr.h:132,
                 from ../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:42:
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:43:21: error: pthread.h: No such file or directory
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:44:20: error: unistd.h: No such file or directory
In file included from ../.././gcc/gthr-default.h:1,
                 from ../../../../src/gcc/libgcc/../gcc/gthr.h:132,
                 from ../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:42:
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:100: error: 'pthread_once' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:101: error: 'pthread_getspecific' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:102: error: 'pthread_setspecific' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:103: error: 'pthread_create' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:104: error: 'pthread_cancel' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:105: error: 'pthread_mutex_lock' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:106: error: 'pthread_mutex_trylock' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:107: error: 'pthread_mutex_unlock' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:108: error: 'pthread_mutex_init' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:109: error: 'pthread_cond_broadcast' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:110: error: 'pthread_cond_wait' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:113: error: 'pthread_key_create' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:114: error: 'pthread_key_delete' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:115: error: 'pthread_mutexattr_init' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:116: error: 'pthread_mutexattr_settype' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:117: error: 'pthread_mutexattr_destroy' undeclared here (not in a function)
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:650: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:659: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:665: error: expected ')' before 'key'
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:671: error: expected ')' before 'key'
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:677: error: expected ')' before 'key'
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:683: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:692: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:701: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:711: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:732: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:738: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:744: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:750: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:756: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/gthr-posix.h:762: error: expected ')' before '*' token
../../../../src/gcc/libgcc/../gcc/unwind-dw2.c: In function 'uw_init_context_1':
../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:1432: error: 'once_regsizes' undeclared (first use in this function)
../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:1432: error: (Each undeclared identifier is reported only once
../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:1432: error: for each function it appears in.)
../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:1432: error: 'PTHREAD_ONCE_INIT' undeclared (first use in this function)
../../../../src/gcc/libgcc/../gcc/unwind-dw2.c:1433: warning: implicit declaration of function '__gthread_once'

IV-C-2. Résolution

Vous avez omis quelque chose lors de la configuration de GCC : en cross-compilation, GCC requiert les POSIX Threads, qui ne sont, ni fournis, ni compilables sous Windows, à cause d'une implémentation POSIX très lacunaire.

Videz le dossier /work/build/gcc et reconfigurez GCC, sans oublier l'option --disable-threads !

IV-D. `CHAR_BIT' undeclared here (not in a function)

IV-D-1. Symptômes

Des messages semblables s'affichent :

 
Sélectionnez
../../../src/gcc/gcc/../libcpp/include/line-map.h:63: error: `CHAR_BIT' undeclared here (not in a function)

IV-D-2. Résolution

À la fin du fichier /gcc/include/stdio.h, ajoutez les lignes :

 
Sélectionnez
#define CHAR_BIT 8

N'oubliez surtout pas la ligne vide finale ! Sinon, de nouvelles erreurs vont arriver :

 
Sélectionnez
stdio.h:649:19: error: no newline at end of file

IV-E. Cannot find a least-32-bit signed integer type

IV-E-1. Symptômes

Ce message apparaît :

 
Sélectionnez
../../../src/gcc/gcc/../libcpp/include/cpplib.h:237:3: #error "Cannot find a least-32-bit signed integer type"

IV-E-2. Résolution

Une des macros utilisées pour déterminer le type à utiliser pour stocker un nombre de 32 bits révèle parfois un bug, ce qui empêche la compilation.
La solution consiste à lui obliger d'utiliser le type le plus grand
Oui, cela consomme plus de ressources systèmes, mais seulement au niveau du compilateur, et la machine qui l'utilise à généralement assez de RAM que pour se permettre d'utiliser quelques octets de plus.

Remplacez donc, dans /work/src/gcc/libcpp/include/libcpp.h, ceci :

 
Sélectionnez
#if CHAR_BIT * SIZEOF_INT >= 32
# define CPPCHAR_SIGNED_T int
#elif CHAR_BIT * SIZEOF_LONG >= 32
# define CPPCHAR_SIGNED_T long
#else
# error "Cannot find a least-32-bit signed integer type"
#endif

Par ceci :

 
Sélectionnez
#if CHAR_BIT * SIZEOF_INT >= 32
# define CPPCHAR_SIGNED_T int
#elif CHAR_BIT * SIZEOF_LONG >= 32
# define CPPCHAR_SIGNED_T long
#else
# define CPPCHAR_SIGNED_T long
#endif

IV-F. `SIZEOF_INT' undeclared

IV-F-1. Symptômes

Ce message apparaît :

 
Sélectionnez
../../../src/gcc/gcc/toplev.h: In function `floor_log2':
../../../src/gcc/gcc/toplev.h:181: error: `SIZEOF_INT' undeclared (first use in this function)
../../../src/gcc/gcc/toplev.h:181: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/toplev.h:181: error: for each function it appears in.)

IV-F-2. Résolution

Toujours suite à un bug dans les macros, SIZEOF_INT ou SIZEOF_LONG ne sont pas déclarés.
Il faut donc le faire manuellement.

Pour ce faire, dans le fichier /work/src/gcc/gcc/toplev.h, ajoutez, avant la fonction floor_log2, au pire, ce bout de code :

 
Sélectionnez
#ifndef SIZEOF_LONG
#define SIZEOF_LONG 4
#endif
#ifndef SIZEOF_INT
#define SIZEOF_INT 4
#endif

Si vous compilez pour du 64 bits, mettez ce bout de code-ci :

 
Sélectionnez
#ifndef SIZEOF_LONG
#define SIZEOF_LONG 8
#endif
#ifndef SIZEOF_INT
#define SIZEOF_INT 4
#endif

IV-G. attempt to use poisoned "bcopy"

IV-G-1. Symptômes

Ce message apparaît :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/../libcpp/include/symtab.h:21,
                 from ../../../src/gcc/gcc/tree.h:1478,
                 from ../../../src/gcc/gcc/c-lang.c:26:
../../../src/gcc/gcc/../include/obstack.h:153:40: attempt to use poisoned "bcopy"

IV-G-2. Résolution

Copiez le fichier /gcc/include/string.h et strings.h dans /work/src/gcc/include.
Au début du fichier /work/src/gcc/include/obstack.h, ajoutez la directive qui signale que nous avons inclus le fichier string.h dans le dossier :

 
Sélectionnez
#ifndef HAVE_STRING_H
#define HAVE_STRING_H
#endif

IV-H. attempt to use poisoned ´strdup'

IV-H-1. Symptômes

Le message suivant apparaît :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/../include/obstack.h:148,
                 from ../../../src/gcc/gcc/../libcpp/include/symtab.h:21,
                 from ../../../src/gcc/gcc/tree.h:1478,
                 from ../../../src/gcc/gcc/c-lang.c:26:
../../../src/gcc/gcc/../include/string.h:92:39: attempt to use poisoned "strdup"

Après l'application de la solution précédente.

IV-H-2. Résolution

Dans le fichier /work/src/gcc/include/string.h, commentez la ligne

 
Sélectionnez
_CRTIMP char* __cdecl __MINGW_NOTHROW	strdup (const char*) __MINGW_ATTRIB_MALLOC;

Ainsi :

 
Sélectionnez
//_CRTIMP char* __cdecl __MINGW_NOTHROW	strdup (const char*) __MINGW_ATTRIB_MALLOC;

IV-I. error: `SIZEOF_LONG' undeclared here

IV-I-1. Symptômes

Un des messages suivants (ou les deux, plus probablement) apparaissent :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:27:
../../../src/gcc/gcc/real.h:57: error: `SIZEOF_LONG' undeclared here (not in a function)
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:27:
../../../src/gcc/gcc/real.h:91:5: division by zero in #if
../../../src/gcc/gcc/real.h:91:5: division by zero in #if
../../../src/gcc/gcc/real.h:94:6: division by zero in #if
../../../src/gcc/gcc/real.h:94:6: division by zero in #if
../../../src/gcc/gcc/real.h:97:7: division by zero in #if
../../../src/gcc/gcc/real.h:97:7: division by zero in #if
../../../src/gcc/gcc/real.h:100:8: division by zero in #if
../../../src/gcc/gcc/real.h:100:8: division by zero in #if
../../../src/gcc/gcc/real.h:103:9: division by zero in #if
../../../src/gcc/gcc/real.h:103:9: division by zero in #if
../../../src/gcc/gcc/real.h:106:10: division by zero in #if
../../../src/gcc/gcc/real.h:106:10: division by zero in #if
../../../src/gcc/gcc/real.h:109:9: #error "REAL_WIDTH > 6 not supported"

IV-I-2. Résolution

Dans le fichier /work/src/gcc/gcc/real.h, ajoutez, après les deux premières directives du préprocesseur, ces quelques lignes :

 
Sélectionnez
#ifndef SIZEOF_LONG
#define SIZEOF_LONG 4
#endif
#ifndef SIZEOF_INT
#define SIZEOF_INT 4
#endif

IV-J. `free' undeclared

IV-J-1. Symptômes

Ces quelques messages apparaissent :

 
Sélectionnez
../../../src/gcc/gcc/c-lex.c: In function `get_fileinfo':
../../../src/gcc/gcc/c-lex.c:112: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/c-lex.c:112: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/c-lex.c:112: error: for each function it appears in.)
../../../src/gcc/gcc/c-lex.c: In function `lex_string':
../../../src/gcc/gcc/c-lex.c:928: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/c-lex.c:951: warning: implicit declaration of function `free'

IV-J-2. Résolution

Je sais que ce genre de solution fait très bricolage, plus que le reste (si, si, c'est possible), mais c'est la seule méthode qui permette de simplement arriver à nos fins ...

Dans le fichier /work/src/gcc/gcc/c-lex.c, faites une recherche sur :

 
Sélectionnez
(splay_tree_delete_value_fn) free

Et remplacez l'occurrence par :

 
Sélectionnez
NULL //(splay_tree_delete_value_fn) free

Recherchez :

 
Sélectionnez
free (CONST_CAST (unsigned char *, istr.text));

Et remplacez cela par :

 
Sélectionnez
//free (CONST_CAST (unsigned char *, istr.text));

IV-K. c-lex.c, c-decl.c, c-common.c

IV-K-1. Symptômes

Vous rencontrez un ou plusieurs de ces nombreux messages (la chaîne "c-lex.c" peut-être remplacée par "c-decl.c" ou "c-common.c") :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:27:
../../../src/gcc/gcc/real.h:57: error: `SIZEOF_LONG' undeclared here (not in a function)
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:27:
../../../src/gcc/gcc/real.h:91:5: division by zero in #if
../../../src/gcc/gcc/real.h:91:5: division by zero in #if
../../../src/gcc/gcc/real.h:94:6: division by zero in #if
../../../src/gcc/gcc/real.h:94:6: division by zero in #if
../../../src/gcc/gcc/real.h:97:7: division by zero in #if
../../../src/gcc/gcc/real.h:97:7: division by zero in #if
../../../src/gcc/gcc/real.h:100:8: division by zero in #if
../../../src/gcc/gcc/real.h:100:8: division by zero in #if
../../../src/gcc/gcc/real.h:103:9: division by zero in #if
../../../src/gcc/gcc/real.h:103:9: division by zero in #if
../../../src/gcc/gcc/real.h:106:10: division by zero in #if
../../../src/gcc/gcc/real.h:106:10: division by zero in #if
../../../src/gcc/gcc/real.h:109:9: #error "REAL_WIDTH > 6 not supported"
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:28:
../../../src/gcc/gcc/c-lex.c: In function `get_fileinfo':
../../../src/gcc/gcc/c-lex.c:112: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/c-lex.c:112: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/c-lex.c:112: error: for each function it appears in.)
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:28:
../../../src/gcc/gcc/c-lex.c: In function `lex_string':
../../../src/gcc/gcc/c-lex.c:928: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/c-lex.c:951: warning: implicit declaration of function `free'
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:32:
../../../src/gcc/gcc/c-lex.c: In function `lex_string':
../../../src/gcc/gcc/c-lex.c:934: error: syntax error before ')' token
 
Sélectionnez
gcc -c   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE
 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute
 -DHAVE_CONFIG_H -I. -I. -I../../../src/gcc/gcc -I../../../src/gcc/gcc/. -I../../../src/gcc/gcc/../include
 -I../../../src/gcc/gcc/../libcpp/include -I/gcc/include -I/gcc/include -I../../../src/gcc/gcc/../libdecnumber
 -I../../../src/gcc/gcc/../libdecnumber/bid -I../libdecnumber
../../../src/gcc/gcc/c-lex.c -o c-lex.o
../../../src/gcc/gcc/c-lex.c:34: warning: function declaration isn't a prototype
../../../src/gcc/gcc/c-lex.c: In function `gcc_obstack_init':
../../../src/gcc/gcc/c-lex.c:35: warning: old-style parameter declaration
../../../src/gcc/gcc/c-lex.c:36: warning: implicit declaration of function `_obstack_begin'
../../../src/gcc/gcc/c-lex.c:36: error: `OBSTACK_CHUNK_SIZE' undeclared (first use in this function)
../../../src/gcc/gcc/c-lex.c:36: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/c-lex.c:36: error: for each function it appears in.)
../../../src/gcc/gcc/c-lex.c:37: error: syntax error before "PARAMS"
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:48:
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_base_quick_insert':
../../../src/gcc/gcc/rtl.h:200: warning: implicit declaration of function `memmove'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_free':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `free'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_copy':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memcpy'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_safe_grow_cleared':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memset'
../../../src/gcc/gcc/c-lex.c: In function `lex_string':
../../../src/gcc/gcc/c-lex.c:950: error: `free' undeclared (first use in this function)
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:46:
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_base_quick_insert':
../../../src/gcc/gcc/rtl.h:200: warning: implicit declaration of function `memmove'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_copy':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memcpy'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_safe_grow_cleared':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memset'
../../../src/gcc/gcc/c-lex.c: In function `lex_string':
../../../src/gcc/gcc/c-lex.c:948: error: syntax error before ')' token
../../../src/gcc/gcc/c-lex.c: In function `cb_ident':
../../../src/gcc/gcc/c-lex.c:200: warning: statement with no effect
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:28:
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_base_quick_insert':
../../../src/gcc/gcc/rtl.h:200: warning: implicit declaration of function `memmove'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_free':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `free'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_copy':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memcpy'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_safe_grow_cleared':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memset'
../../../src/gcc/gcc/c-lex.c:59:29: attempt to use poisoned "malloc"
../../../src/gcc/gcc/c-lex.c: At top level:
../../../src/gcc/gcc/c-lex.c:65: warning: function declaration isn't a prototype
../../../src/gcc/gcc/c-lex.c: In function `gcc_obstack_init':
../../../src/gcc/gcc/c-lex.c:66: warning: old-style parameter declaration
../../../src/gcc/gcc/c-lex.c:68: error: `malloc' undeclared (first use in this function)
../../../src/gcc/gcc/c-lex.c:68: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/c-lex.c:68: error: for each function it appears in.)
../../../src/gcc/gcc/c-lex.c: In function `cb_ident':
../../../src/gcc/gcc/c-lex.c:211: warning: statement with no effect
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:28:
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_base_quick_insert':
../../../src/gcc/gcc/rtl.h:200: warning: implicit declaration of function `memmove'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_free':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `free'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_copy':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memcpy'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_safe_grow_cleared':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memset'
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:47:
/gcc/include/stdlib.h:359:39: attempt to use poisoned "calloc"
/gcc/include/stdlib.h:360:39: attempt to use poisoned "malloc"
/gcc/include/stdlib.h:361:39: attempt to use poisoned "realloc"
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:47:
/gcc/include/stdlib.h: At top level:
/gcc/include/stdlib.h:362: error: conflicting types for 'free'
../../../src/gcc/gcc/rtl.h:201: error: previous implicit declaration of 'free' was here
/gcc/include/stdlib.h:363:49: macro "abort" passed 1 arguments, but takes just 0
/gcc/include/stdlib.h:363: warning: `__noreturn__' attribute ignored
/gcc/include/stdlib.h:363: warning: `__cdecl__' attribute only applies to function types
/gcc/include/stdlib.h:363: warning: `__nothrow__' attribute ignored
/gcc/include/stdlib.h:363: warning: built-in function 'abort' declared as non-function
../../../src/gcc/gcc/c-lex.c:61:29: attempt to use poisoned "malloc"
../../../src/gcc/gcc/c-lex.c:67: warning: function declaration isn't a prototype
../../../src/gcc/gcc/c-lex.c: In function `gcc_obstack_init':
../../../src/gcc/gcc/c-lex.c:68: warning: old-style parameter declaration
../../../src/gcc/gcc/c-lex.c:70: error: cast specifies function type
../../../src/gcc/gcc/c-lex.c: In function `cb_ident':
../../../src/gcc/gcc/c-lex.c:213: warning: statement with no effect
../../../src/gcc/gcc/c-lex.c: At top level:
/gcc/include/stdlib.h:363: error: storage size of `abort' isn't known
 
Sélectionnez
In file included from ../../../src/gcc/gcc/c-lex.c:35:
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_base_quick_insert':
../../../src/gcc/gcc/rtl.h:200: warning: implicit declaration of function `memmove'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_copy':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memcpy'
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_safe_grow_cleared':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `memset'
../../../src/gcc/gcc/c-lex.c:66:29: attempt to use poisoned "malloc"
../../../src/gcc/gcc/c-lex.c: At top level:
../../../src/gcc/gcc/c-lex.c:72: warning: function declaration isn't a prototype
../../../src/gcc/gcc/c-lex.c: In function `gcc_obstack_init':
../../../src/gcc/gcc/c-lex.c:73: warning: old-style parameter declaration

IV-K-2. Résolution

En fait, tout ceci est produit par une fonction qui n'est pas compréhensible par GCC (même s'il contient cette instruction).
Ensuite, il essaye d'utiliser une version d'une fonction, mais qui n'est plus assez sécurisée, paraît-il.

Ouvrez le fichier /work/src/gcc/gcc/c-lex.c.
AVANT tous les includes, insérez ce bout de code :

 
Sélectionnez
#include "c-patch.h"

Créez un fichier c-patch.h dans ce dossier qui contient ceci :

 
Sélectionnez
#ifndef __C_PATCH_H__
#define __C_PATCH_H__

#include <malloc.h>
#include <stdlib.h>

#endif

APRÈS tous les includes, insérez ce bout de code :

 
Sélectionnez
#include "c-patch.c"

Créez un nouveau fichier c-patch.c qui contient ceci :

 
Sélectionnez
#ifndef __C_PATCH_C__
#define __C_PATCH_C__

#ifndef free
#define free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif

#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 4096
#endif

#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
#endif

#ifndef OBSTACK_CHUNK_FREE
#define OBSTACK_CHUNK_FREE free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif
static incline
void
gcc_obstack_init (obstack)
{
  _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, 0,
		  (void *(*) PARAMS ((long ))) OBSTACK_CHUNK_ALLOC,
		  NULL /*(void (*) PARAMS ((void *))) OBSTACK_CHUNK_FREE */);
}

#ifdef obstack_init
#undef obstack_init
#endif
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, (void *(*) (long)) obstack_chunk_alloc, NULL/*(void (*) (void *)) obstack_chunk_free*/)

#endif

IV-L. c-incpath.c

IV-L-1. Symptômes

Ce genre de messages apparaît :

 
Sélectionnez
../../../src/gcc/gcc/c-incpath.c: In function `remove_duplicates':
../../../src/gcc/gcc/c-incpath.c:217: error: storage size of 'st' isn't known
../../../src/gcc/gcc/c-incpath.c:225: warning: implicit declaration of function `stat'
../../../src/gcc/gcc/c-incpath.c:239: error: `S_IFMT' undeclared (first use in this function)
../../../src/gcc/gcc/c-incpath.c:239: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/c-incpath.c:239: error: for each function it appears in.)
../../../src/gcc/gcc/c-incpath.c:239: error: `S_IFDIR' undeclared (first use in this function)
../../../src/gcc/gcc/c-incpath.c:217: warning: unused variable `st'

IV-L-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/c-incpath.c, cherchez la ligne qui contient ceci (aux environs de la ligne 240) :

 
Sélectionnez
else if (!S_ISDIR (st.st_mode))

Remplacez-la par ceci :

 
Sélectionnez
#undef S_ISDIR
#ifdef S_ISDIR
      else if (!S_ISDIR (st.st_mode))
#elif defined _S_ISDIR
      else if (!_S_ISDIR (st.st_mode))
#else
      else if (st.st_mode != 0040000)
#endif

Ensuite, à la suite de la liste des includes, au sommet, ajoutez ces quelques lignes :

 
Sélectionnez
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <malloc.h>

Faites une copie des fichiers /gcc/include/stdlib.h et _mingw.h dans /work/src/gcc/gcc/.
Recherchez ceci (aux alentours de la ligne 360):

 
Sélectionnez
_CRTIMP void* __cdecl __MINGW_NOTHROW	calloc	(size_t, size_t) __MINGW_ATTRIB_MALLOC;
_CRTIMP void* __cdecl __MINGW_NOTHROW	malloc	(size_t) __MINGW_ATTRIB_MALLOC;
_CRTIMP void* __cdecl __MINGW_NOTHROW	realloc	(void*, size_t);
_CRTIMP void __cdecl __MINGW_NOTHROW	free	(void*);
_CRTIMP void __cdecl __MINGW_NOTHROW	abort	(void) __MINGW_ATTRIB_NORETURN;
_CRTIMP void __cdecl __MINGW_NOTHROW	exit	(int) __MINGW_ATTRIB_NORETURN;

Et remplacez-le par :

 
Sélectionnez
//_CRTIMP void* __cdecl __MINGW_NOTHROW	calloc	(size_t, size_t) __MINGW_ATTRIB_MALLOC;
//_CRTIMP void* __cdecl __MINGW_NOTHROW	malloc	(size_t) __MINGW_ATTRIB_MALLOC;
//_CRTIMP void* __cdecl __MINGW_NOTHROW	realloc	(void*, size_t);
_CRTIMP void __cdecl __MINGW_NOTHROW	free	(void*);
//_CRTIMP void __cdecl __MINGW_NOTHROW	abort	(void) __MINGW_ATTRIB_NORETURN;
_CRTIMP void __cdecl __MINGW_NOTHROW	exit	(int) __MINGW_ATTRIB_NORETURN;

IV-M. c-cppbuiltin.c

IV-M-1. Symptômes

Ce message s'affiche :

 
Sélectionnez
../../../src/gcc/gcc/c-cppbuiltin.c: In function `c_cpp_builtins':
../../../src/gcc/gcc/c-cppbuiltin.c:730: error: `ENABLE_DECIMAL_FLOAT' undeclared (first use in this function)
../../../src/gcc/gcc/c-cppbuiltin.c:730: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/c-cppbuiltin.c:730: error: for each function it appears in.)
../../../src/gcc/gcc/c-cppbuiltin.c:730: error: `ENABLE_DECIMAL_BID_FORMAT' undeclared (first use in this function)

IV-M-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/c-cppbuiltin-c et ajoutez, à la fin des includes, ceci :

 
Sélectionnez
#define ENABLE_DECIMAL_FLOAT		0
#define ENABLE_DECIMAL_BID_FORMAT	0

IV-N. hard-reg-set.h

IV-N-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/tree-mudflap.c:28:
../../../src/gcc/gcc/hard-reg-set.h:53: error: `SIZEOF_LONG' undeclared here (not in a function)
../../../src/gcc/gcc/hard-reg-set.h:434: warning: type defaults to `int' in declaration of `x'
../../../src/gcc/gcc/hard-reg-set.h:434: warning: type defaults to `int' in declaration of `y'
../../../src/gcc/gcc/hard-reg-set.h: In function `hard_reg_set_subset_p':
../../../src/gcc/gcc/hard-reg-set.h:439: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h:439: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h: At top level:
../../../src/gcc/gcc/hard-reg-set.h:445: warning: type defaults to `int' in declaration of `x'
../../../src/gcc/gcc/hard-reg-set.h:445: warning: type defaults to `int' in declaration of `y'
../../../src/gcc/gcc/hard-reg-set.h: In function `hard_reg_set_equal_p':
../../../src/gcc/gcc/hard-reg-set.h:450: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h:450: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h: At top level:
../../../src/gcc/gcc/hard-reg-set.h:456: warning: type defaults to `int' in declaration of `x'
../../../src/gcc/gcc/hard-reg-set.h:456: warning: type defaults to `int' in declaration of `y'
../../../src/gcc/gcc/hard-reg-set.h: In function `hard_reg_set_intersect_p':
../../../src/gcc/gcc/hard-reg-set.h:461: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h:461: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h: At top level:
../../../src/gcc/gcc/hard-reg-set.h:467: warning: type defaults to `int' in declaration of `x'
../../../src/gcc/gcc/hard-reg-set.h: In function `hard_reg_set_empty_p':
../../../src/gcc/gcc/hard-reg-set.h:472: error: subscripted value is neither array nor pointer
../../../src/gcc/gcc/hard-reg-set.h: At top level:
../../../src/gcc/gcc/hard-reg-set.h:493: warning: type defaults to `int' in declaration of `fixed_reg_set'
../../../src/gcc/gcc/hard-reg-set.h:508: warning: type defaults to `int' in declaration of `call_used_reg_set'
../../../src/gcc/gcc/hard-reg-set.h:511: warning: type defaults to `int' in declaration of `losing_caller_save_reg_set'
../../../src/gcc/gcc/hard-reg-set.h:523: warning: type defaults to `int' in declaration of `call_fixed_reg_set'
../../../src/gcc/gcc/hard-reg-set.h:539: warning: type defaults to `int' in declaration of `regs_invalidated_by_call'
../../../src/gcc/gcc/hard-reg-set.h:553: warning: type defaults to `int' in declaration of `reg_class_contents'

IV-N-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/hard-reg-set.h et ajoutez ces quelques lignes, vers le début (après les deux premières instructions de préprocesseur) :

 
Sélectionnez
#ifndef SIZEOF_LONG
#define SIZEOF_LONG 4
#endif
#ifndef SIZEOF_INT
#define SIZEOF_INT 4
#endif

IV-O. bb-reorder.c

IV-O-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
../../../src/gcc/gcc/bb-reorder.c: In function `find_traces':
../../../src/gcc/gcc/bb-reorder.c:262: error: `INT_MAX' undeclared (first use in this function)
../../../src/gcc/gcc/bb-reorder.c:262: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/bb-reorder.c:262: error: for each function it appears in.)
../../../src/gcc/gcc/bb-reorder.c: In function `find_traces_1_round':
../../../src/gcc/gcc/bb-reorder.c:484: error: `INT_MIN' undeclared (first use in this function)
../../../src/gcc/gcc/bb-reorder.c: In function `connect_traces':
../../../src/gcc/gcc/bb-reorder.c:910: error: `INT_MAX' undeclared (first use in this function)

IV-O-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/bb-reorder.c et ajoutez cet include, à la fin de la liste :

 
Sélectionnez
#include <limits.h>

IV-P. bitmap.c

IV-P-1. Symptômes

Ces messages d'erreurs apparaissent :

 
Sélectionnez
../../../src/gcc/gcc/bitmap.c: In function `bitmap_obstack_initialize':
../../../src/gcc/gcc/bitmap.c:313: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/bitmap.c:313: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/bitmap.c:313: error: for each function it appears in.)

IV-P-2. Résolution

Si ce n'est déjà fait, copiez les fichiers /gcc/include/stdlib.h et _mingw.h dans /work/src/gcc/gcc/.

Ouvrez le nouvellement copié stdlib.h et remplacez ce bout de code (aux alentours de la ligne 360) :

 
Sélectionnez
_CRTIMP void* __cdecl __MINGW_NOTHROW	calloc	(size_t, size_t) __MINGW_ATTRIB_MALLOC;
_CRTIMP void* __cdecl __MINGW_NOTHROW	malloc	(size_t) __MINGW_ATTRIB_MALLOC;
_CRTIMP void* __cdecl __MINGW_NOTHROW	realloc	(void*, size_t);
_CRTIMP void __cdecl __MINGW_NOTHROW	free	(void*);
_CRTIMP void __cdecl __MINGW_NOTHROW	abort	(void) __MINGW_ATTRIB_NORETURN;
_CRTIMP void __cdecl __MINGW_NOTHROW	exit	(int) __MINGW_ATTRIB_NORETURN;

Par celui-ci :

 
Sélectionnez
//_CRTIMP void* __cdecl __MINGW_NOTHROW	calloc	(size_t, size_t) __MINGW_ATTRIB_MALLOC;
//_CRTIMP void* __cdecl __MINGW_NOTHROW	malloc	(size_t) __MINGW_ATTRIB_MALLOC;
//_CRTIMP void* __cdecl __MINGW_NOTHROW	realloc	(void*, size_t);
//_CRTIMP void __cdecl __MINGW_NOTHROW	free	(void*);
//_CRTIMP void __cdecl __MINGW_NOTHROW	abort	(void) __MINGW_ATTRIB_NORETURN;
_CRTIMP void __cdecl __MINGW_NOTHROW	exit	(int) __MINGW_ATTRIB_NORETURN;

Ouvrez le fichier /work/src/gcc/gcc/bitmap.c, ajoutez ceci, après tous les includes :

 
Sélectionnez
#ifdef free
#undef free
#endif
#ifdef alloca
#undef alloca
#endif
#include <malloc.h>

IV-Q. read-rtl.c

IV-Q-1. Symptômes

Ces messages apparaissent ("read-rtl.c" peut être remplacé par "gensupport.c") :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/read-rtl.c:30:
../../../src/gcc/gcc/rtl.h: In function `VEC_rtx_heap_free':
../../../src/gcc/gcc/rtl.h:201: warning: implicit declaration of function `free'
../../../src/gcc/gcc/read-rtl.c: In function `apply_iterator_to_string':
../../../src/gcc/gcc/read-rtl.c:401: warning: implicit declaration of function `alloca'
../../../src/gcc/gcc/read-rtl.c: In function `read_rtx':
../../../src/gcc/gcc/read-rtl.c:1410: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/read-rtl.c:1410: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/read-rtl.c:1410: error: for each function it appears in.)
../../../src/gcc/gcc/read-rtl.c: In function `read_rtx_1':
../../../src/gcc/gcc/read-rtl.c:1600: error: `free' undeclared (first use in this function)

IV-Q-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/read-rtl.c (ou gensupport.c).
AVANT tous les includes, insérez ce bout de code :

 
Sélectionnez
#include "c-patch.h"

Créez un fichier c-patch.h dans ce dossier qui contient ceci, si ce n'est déjà fait :

 
Sélectionnez
#ifndef __C_PATCH_H__
#define __C_PATCH_H__

#include <malloc.h>
#include <stdlib.h>

#endif

APRÈS tous les includes, insérez ce bout de code :

 
Sélectionnez
#include "c-patch.c"

Créez un nouveau fichier c-patch.c qui contient ceci, si ce n'est déjà fait :

 
Sélectionnez
#ifndef __C_PATCH_C__
#define __C_PATCH_C__

#ifndef free
#define free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif

#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 4096
#endif

#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
#endif

#ifndef OBSTACK_CHUNK_FREE
#define OBSTACK_CHUNK_FREE free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif
void
gcc_obstack_init (obstack)
{
  _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, 0,
		  (void *(*) PARAMS ((long ))) OBSTACK_CHUNK_ALLOC,
		  NULL /*(void (*) PARAMS ((void *))) OBSTACK_CHUNK_FREE */);
}

#ifdef obstack_init
#undef obstack_init
#endif
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, (void *(*) (long)) obstack_chunk_alloc, NULL/*(void (*) (void *)) obstack_chunk_free*/)

#endif

IV-R. gensupport.c

IV-R-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
In file included from ../../../src/gcc/gcc/gensupport.c:33:
../../../src/gcc/gcc/gensupport.c: At top level:
../../../src/gcc/gcc/gensupport.c:48: warning: initialization from incompatible pointer type
../../../src/gcc/gcc/gensupport.c: In function `init_predicate_table':
../../../src/gcc/gcc/gensupport.c:1367: error: syntax error before ')' token
../../../src/gcc/gcc/gensupport.c: In function `read_md_rtx':
../../../src/gcc/gcc/gensupport.c:1107: warning: statement with no effect

IV-R-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/gensupport.c.
AVANT tous les include, insérez ce bout de code :

 
Sélectionnez
#include "c-patch.h"

Créez un fichier c-patch.h dans ce dossier qui contient ceci, si ce n'est déjà fait :

 
Sélectionnez
#ifndef __C_PATCH_H__
#define __C_PATCH_H__

#include <malloc.h>
#include <stdlib.h>

#endif

APRÈS tous les includes, insérez ce bout de code :

 
Sélectionnez
#include "c-patch.c"

Créez un nouveau fichier c-patch.c qui contient ceci, si ce n'est déjà fait :

 
Sélectionnez
#ifndef __C_PATCH_C__
#define __C_PATCH_C__

#ifndef free
#define free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif

#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 4096
#endif

#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
#endif

#ifndef OBSTACK_CHUNK_FREE
#define OBSTACK_CHUNK_FREE free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif
void
gcc_obstack_init (obstack)
{
  _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, 0,
		  (void *(*) PARAMS ((long ))) OBSTACK_CHUNK_ALLOC,
		  NULL /*(void (*) PARAMS ((void *))) OBSTACK_CHUNK_FREE */);
}

#ifdef obstack_init
#undef obstack_init
#endif
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, (void *(*) (long)) obstack_chunk_alloc, NULL/*(void (*) (void *)) obstack_chunk_free*/)

#endif

Ensuite, recherchez ce bout de code dans le fichier :

 
Sélectionnez
predicate_table = htab_create_alloc (37, hash_struct_pred_data,
				       eq_struct_pred_data, 0,
				       xcalloc, free);

Et remplacez-le par :

 
Sélectionnez
predicate_table = htab_create_alloc (37, hash_struct_pred_data,
				       eq_struct_pred_data, 0,
				       xcalloc, NULL/*free*/);

IV-S. genmodes.c

IV-S-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
../../../src/gcc/gcc/genmodes.c: In function `main':
../../../src/gcc/gcc/genmodes.c:1393: error: `free' undeclared (first use in this function)
../../../src/gcc/gcc/genmodes.c:1393: error: (Each undeclared identifier is reported only once
../../../src/gcc/gcc/genmodes.c:1393: error: for each function it appears in.)

IV-S-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/genmodes.c et recherchez cette ligne (aux environs de la ligne 1390) :

 
Sélectionnez
modes_by_name = htab_create_alloc (64, hash_mode, eq_mode, 0, xcalloc, NULL/*free*/);

Et remplacez-la par :

 
Sélectionnez
modes_by_name = htab_create_alloc (64, hash_mode, eq_mode, 0, xcalloc, NULL/*free*/);

IV-T. multiple definition of `gcc_obstack_init'

IV-T-1. Symptômes

Vous avez installé un patch qui utilise les fichiers c-patch.h et c-patch.c.

Ces messages d'erreurs apparaissent :

 
Sélectionnez
/work/build/gcc/gcc/../../../src/gcc/gcc/c-patch.c:33: multiple definition of `gcc_obstack_init'
build/read-rtl.o:A:/work/build/gcc/gcc/../../../src/gcc/gcc/c-patch.c:33: first defined here

IV-T-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/c-patch.c et changez-le pour qu'il ressemble à ceci :

 
Sélectionnez
#ifndef __C_PATCH_C__
#define __C_PATCH_C__

#ifndef free
#define free
#endif

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif

#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 4096
#endif

#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
#endif

#ifndef OBSTACK_CHUNK_FREE
#define OBSTACK_CHUNK_FREE free
#endif

struct obstack *obstack;

#ifdef gcc_obstack_init
#undef gcc_obstack_init
#endif
void
gcc_obstack_init (obstack);

#ifdef obstack_init
#undef obstack_init
#endif
#define obstack_init(h) \
_obstack_begin ((h), 0, 0, (void *(*) (long)) obstack_chunk_alloc, NULL/*(void (*) (void *)) obstack_chunk_free*/)

#endif

Puis créez, dans le même répertoire, le fichier c-patch.c.c, qui contient ceci :

 
Sélectionnez
#include "c-patch.c"

void
gcc_obstack_init (obstack)
{
  _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, 0,
		  (void *(*) PARAMS ((long ))) OBSTACK_CHUNK_ALLOC,
		  NULL /*(void (*) PARAMS ((void *))) OBSTACK_CHUNK_FREE */);
}

V. Compilation de GCC 4.4.0 SVN

V-A. GNU make version 3.80 or newer is required

V-A-1. Symptômes

Ce message apparaît :

 
Sélectionnez
Makefile:26: *** GNU make version 3.80 or newer is required..  Stop.

V-A-2. Résolution

Téléchargez la dernière version de MinGW Make et décompressez-la directement dans le répertoire de votre compilateur.

V-B. No rule to make target `|', needed by `c-lang.o'

V-B-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
make[2]: *** No rule to make target `|', needed by `c-lang.o'.  Stop.
make[2]: Leaving directory `/work/build/gcc/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/work/build/gcc'
make: *** [all] Error 2

V-B-2. Résolution

Ouvrez le fichier /work/build/gcc/gcc/Makefile, et ajoutez cette ligne, tout à la fin du fichier (faites attention à ne pas mettre le moindre espace devant) :

 
Sélectionnez
|:

Vous pouvez faire la même chose dans /work/src/gcc/gcc/Makefile.in, mais vous devrez reconfigurer (si vous reconfigurez plus tard, ces modifications seront gardées).

V-C. gt-expr.h

V-C-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
./gt-expr.h: At top level:
./gt-expr.h:26: error: `class_ident' undeclared here (not in a function)
./gt-expr.h:26: error: initializer element is not constant
./gt-expr.h:26: error: (near initialization for `gt_ggc_r_gt_expr_h[0].base')
./gt-expr.h:31: error: initializer element is not constant
./gt-expr.h:31: error: (near initialization for `gt_ggc_r_gt_expr_h[0]')
./gt-expr.h:33: error: `page_size' undeclared here (not in a function)
./gt-expr.h:33: error: initializer element is not constant
./gt-expr.h:33: error: (near initialization for `gt_ggc_r_gt_expr_h[1].base')
./gt-expr.h:38: error: initializer element is not constant
./gt-expr.h:38: error: (near initialization for `gt_ggc_r_gt_expr_h[1]')
./gt-expr.h:40: error: `quick_stack' undeclared here (not in a function)
./gt-expr.h:40: error: initializer element is not constant
./gt-expr.h:40: error: (near initialization for `gt_ggc_r_gt_expr_h[2].base')
./gt-expr.h:45: error: initializer element is not constant
./gt-expr.h:45: error: (near initialization for `gt_ggc_r_gt_expr_h[2]')
./gt-expr.h:47: error: `ncode_ident' undeclared here (not in a function)
./gt-expr.h:47: error: initializer element is not constant
./gt-expr.h:47: error: (near initialization for `gt_ggc_r_gt_expr_h[3].base')
./gt-expr.h:52: error: initializer element is not constant
./gt-expr.h:52: error: (near initialization for `gt_ggc_r_gt_expr_h[3]')
./gt-expr.h:54: error: `methods_ident' undeclared here (not in a function)
./gt-expr.h:54: error: initializer element is not constant
./gt-expr.h:54: error: (near initialization for `gt_ggc_r_gt_expr_h[4].base')
./gt-expr.h:59: error: initializer element is not constant
./gt-expr.h:59: error: (near initialization for `gt_ggc_r_gt_expr_h[4]')
./gt-expr.h:61: error: `operand_type' undeclared here (not in a function)
./gt-expr.h:61: error: initializer element is not constant
./gt-expr.h:61: error: (near initialization for `gt_ggc_r_gt_expr_h[5].base')
./gt-expr.h:66: error: initializer element is not constant
./gt-expr.h:66: error: (near initialization for `gt_ggc_r_gt_expr_h[5]')
./gt-expr.h:73: error: initializer element is not constant
./gt-expr.h:73: error: (near initialization for `gt_ggc_r_gt_expr_h[6]')
./gt-expr.h:74: error: initializer element is not constant
./gt-expr.h:74: error: (near initialization for `gt_ggc_r_gt_expr_h[7]')
./gt-expr.h:78: error: `tree_list_free_list' undeclared here (not in a function)
./gt-expr.h:78: error: initializer element is not constant
./gt-expr.h:78: error: (near initialization for `gt_ggc_rd_gt_expr_h[0].base')
./gt-expr.h:78: error: initializer element is not constant
./gt-expr.h:78: error: (near initialization for `gt_ggc_rd_gt_expr_h[0]')
./gt-expr.h:79: error: initializer element is not constant
./gt-expr.h:79: error: (near initialization for `gt_ggc_rd_gt_expr_h[1]')

V-C-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/expr.c et, à la toute fin, juste avant l'include de gt-expr.h, ajoutez ces quelques lignes :

 
Sélectionnez
static GTY(()) tree class_ident;
static tree page_size;
static tree quick_stack; //  = NULL_TREE
static tree ncode_ident; //  = NULL_TREE
static tree methods_ident; //  = NULL_TREE
static tree operand_type[59];
static tree block_move_fn;
static tree tree_list_free_list; //  = NULL_TREE

V-D. cannot open output file build/genconfig.exe: Permission denied

V-D-1. Symptômes

Le message suivant apparaît :

 
Sélectionnez
cannot open output file build/genconfig.exe: Permission denied

V-D-2. Résolution

Tuez le processus genconfig.exe à l'aide du Gestionnaire des Tâches.

V-E. gtype-desc.c

V-E-1. Symptômes

Quelques centaines d'écrans vous avertissent d'erreurs concernant gtype-desc.c, comme, par exemple :

 
Sélectionnez
gtype-desc.c:14759: error: `LAST_REASON_CODE' undeclared here (not in a function)
gtype-desc.c:14759: error: initializer element is not constant
gtype-desc.c:14759: error: (near initialization for `gt_ggc_r_gtype_desc_c[95].nelt')

V-E-2. Résolution

Ouvrez le fichier /work/src/gcc/gcc/Makefile, faites une recherche sur gtype-desc.c et ne laissez plus subsister que l'occurence dans la cible gtype-desc.o.

Ouvrez le fichier /work/src/gcc/gcc/ et ajoutez, à la fin (avant la toute dernière instruction du préprocesseur) :

 
Sélectionnez
#include "tree.h"
	
extern GTY(()) struct imp_entry *imp_list;
extern GTY(()) int imp_count;
extern GTY(()) int cat_count;

extern GTY(()) enum tree_code objc_inherit_code;
extern GTY(()) int objc_public_flag;
	
#ifndef LAST_REASON_CODE
#define LAST_REASON_CODE 32
#endif

extern GTY(()) tree gnat_raise_decls;

extern GTY(()) union tree_node global_namespace;
static GTY(()) tree global_scope_name;

static tree global_type_node;

N'oubliez pas de mettre le fichier en lecture seule, pour éviter qu'il soit modifié par la suite !

Si, par la suite, les mêmes erreurs se reproduisent et que le Makefile a été modifié, répétez la première option, mettez le Makefile en lecture seule et recopiez les fichiers gtype-desc.c et gtype-desc.h de la version précédente de GCC, que vous avez compilé avec succès.

Toujours pas arrivé plus loin ? Combinez les deux solutions !

On vous parle de redéfinitions tout le temps ? Ajoutez des blocs dans ce style au début de chaque include gtype-.

 
Sélectionnez
#ifndef FICHIER_H
#define FICHIER_H

//...

#endif

V-F. libbackend.a

V-F-1. Symptômes

 
Sélectionnez
libbackend.a(dce.o): In function `init_dce':
A:/work/src/gcc/gcc/dce.c:673: undefined reference to `dump_file'
A:/work/src/gcc/gcc/dce.c:682: undefined reference to `sbitmap_alloc'
A:/work/src/gcc/gcc/dce.c:683: undefined reference to `sbitmap_zero'
A:/work/src/gcc/gcc/dce.c:682: undefined reference to `sbitmap_alloc'
A:/work/src/gcc/gcc/dce.c:683: undefined reference to `sbitmap_zero'
libbackend.a(dce.o): In function `rest_of_handle_ud_dce':
A:/work/src/gcc/gcc/dce.c:648: undefined reference to `dump_file'
A:/work/src/gcc/gcc/dce.c:648: undefined reference to `dump_file'
A:/work/src/gcc/gcc/dce.c:651: undefined reference to `dump_file'
A:/work/src/gcc/gcc/dce.c:651: undefined reference to `print_simple_rtl'
A:/work/src/gcc/gcc/dce.c:652: undefined reference to `dump_file'

V-F-2. Résolution

make a loupé la compilation de gtype-desc.c.

Essayez donc de recompiler, puis de nettoyer et recompiler, puis de reconfigurer.

VI. Compilation de GCC 4.3.0 (MinGW)

VI-A. filename `ada-tree.h should be preceded by $srcdir

VI-A-1. Symptômes

Le message d'erreur suivant apparaît :

 
Sélectionnez
gengtype: filename `/work/src/gcc/gcc/ada/ada-tree.h' should be preceded by $srcdir

VI-A-2. Résolution

Dans le fichier /work/src/gcc/gcc/gentype.c, aux environs de la ligne 1580, recherchez et commentez cette ligne :

 
Sélectionnez
fatal ("filename `%s' should be preceded by $srcdir", f);

VI-B. bid_decimal_globals.c

VI-B-1. Symptômes

Ces messages apparaissent :

 
Sélectionnez
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:52:18: error: fenv.h: No such file or directory
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c: In function '__dfp_test_except':
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:64: error: 'FE_INEXACT' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:64: error: (Each undeclared identifier is reported only once
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:64: error: for each function it appears in.)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:66: error: 'FE_UNDERFLOW' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:68: error: 'FE_OVERFLOW' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:70: error: 'FE_DIVBYZERO' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:72: error: 'FE_INVALID' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c: In function '__dfp_raise_except':
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:81: error: 'FE_INEXACT' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:83: error: 'FE_UNDERFLOW' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:85: error: 'FE_OVERFLOW' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:87: error: 'FE_DIVBYZERO' undeclared (first use in this function)
A:/work/src/gcc/libgcc/config/libbid/bid_decimal_globals.c:89: error: 'FE_INVALID' undeclared (first use in this function)

VI-B-2. Résolution

Ouvrez le fichier /work/build/gcc/i586-pc-linux-gnu/libgcc/Makefile, trouvez la variable CFLAGS et ajoutez-y le drapeau -frounding-math. Au final, cela devrait ressembler à ceci :

 
Sélectionnez
CFLAGS = -O2 -g -frounding-math

Si cela ne suffit pas, reconfigurez avec le paramètre --disable-decimal-float en plus.

VI-C. Cannot create executables

VI-C-1. Symptômes

Ce message d'erreur apparaît :

 
Sélectionnez
configure: error: C compiler cannot create executables

VI-C-2. Résolution

La compilation de LibGOMP ne peut s'effectuer dans un cross-compilateur, or GCC l'active par défaut, quelques fois, sans laisser de possibilité de désactivation.

Supprimez toutes les occurences de LibGOMP dans /work/build/gcc/Makefile, ainsi que tous leurs paragraphes.

VI-D. Link tests are not allowed after GCC_NO_EXECUTABLES

VI-D-1. Symptômes

Ce message d'erreur apparaît :

 
Sélectionnez
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.

VI-D-2. Résolution

La librairie standard C++ ne veut pas se compiler et ne voudra très probablement pas dans un futur proche. Préférez donc l'utilisation d'une autre bibliothèque, comme, par exemple, µClibC++, ou STLPort, ou Apache C++ Standard Library, dès que le compilateur sera en mesure de l'utiliser. Avant, donc, il faut en désactiver la compilation.

Pour ce faire, supprimez toutes les occurences de libstdc++-v3 de /work/build/gcc/Makefile

VI-E. configure-target-libssp

VI-E-1. Symptômes

Ce message d'erreur apparaît :

 
Sélectionnez
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
make[1]: *** [configure-target-libssp] Error 1
make[1]: Leaving directory `/work/build/gcc'
make: *** [all] Error 2

VI-E-2. Résolution

Dans le fichier /work/src/gcc/configure, recherchez la ligne

 
Sélectionnez
Disable libmudflap on some systems

Et supprimez tout jusqu'à la ligne

 
Sélectionnez
noconfigdirs="$noconfigdirs target-libmudflap"

précédentsommairesuivant

Copyright © 2009 Thibaut Cuvelier. Aucune reproduction, même partielle, ne peut être faite de ce site ni de l'ensemble de son contenu : textes, documents, images, etc. sans l'autorisation expresse de l'auteur. Sinon vous encourez selon la loi jusqu'à trois ans de prison et jusqu'à 300 000 € de dommages et intérêts.