On Sun, Mar 22, 2015 at 02:36:31PM +0800, xue yinsong wrote:
> I add the following code in parser.c to replace htab:
> 
> …
> struct gimple_symtab_hasher : ggc_cache_hasher<struct gimple_symtab_entry_def 
> *>
> {
>   /* Return the hash value of the declaration name of a 
> gimple_symtab_entry_def
>   object pointed by ENTRY.  */
>   static hashval_t hash(struct gimple_symtab_entry_def *base){return 
> IDENTIFIER_HASH_VALUE(base->id);}
>   /* Returns non-zero if ENTRY1 and ENTRY2 point to gimple_symtab_entry_def
>   objects corresponding to the same declaration.  */
>   static bool equal (const struct gimple_symtab_entry_def *base1, const 
> struct gimple_symtab_entry_def *base2){return base1->id == base2->id;}
>   static void 
>   handle_cache_entry(struct gimple_symtab_entry_def *&m)
>   {
>     extern void gt_ggc_mx (struct gimple_symtab_entry_def *&);
>     if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
>       return;
>     else if (ggc_marked_p (m->id))
>       gt_ggc_mx (m);
>     else
>       m = static_cast<struct gimple_symtab_entry_def *> (HTAB_DELETED_ENTRY);
>   }
> };
> 
> /* Gimple symbol table.  */
> static GTY((cache)) hash_table<gimple_symtab_hasher> *gimple_symtab;
> …
> 
> But I got undefined symbols when compiling it:
> …
> Undefined symbols for architecture x86_64:
>   "gt_ggc_mx(gimple_symtab_entry_def*&)", referenced from:
>       gt_clear_caches_gt_gimple_parser_h()     in parser.o
>   "gt_pch_nx(gimple_symtab_entry_def*&)", referenced from:
>       gt_pch_nx_hash_table_gimple_symtab_hasher_(void*) in parser.o
>   "_c_global_trees", referenced from:
>       gimple_main()     in parser.o
> ld: symbol(s) not found for architecture x86_64
> collect2: error: ld returned 1 exit status
> make[3]: *** [gimple1] Error 1
> make[2]: *** [all-stage2-gcc] Error 2
> make[1]: *** [stage2-bubble] Error 2
> make: *** [all] Error 2
> 
> Could someone tell me how to fix this?

I believe making the GTY marker for gimple_symtab_entry_def GTY
((for_user)) will cause gengtype to generate the needed marking routines
and so fix the link error.

Trev

> 
> 
> 
> —
> Regards,
> Yinsong
> >
> 

Reply via email to