Bug 20712 - gdb 7.12+ doesn't build as C++ on Solaris
Summary: gdb 7.12+ doesn't build as C++ on Solaris
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: build (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 7.12.1
Assignee: Rainer Orth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-18 13:04 UTC by Rainer Orth
Modified: 2016-10-26 12:34 UTC (History)
2 users (show)

See Also:
Host: *-*-solaris2.*
Target: *-*-solaris2.*
Build: *-*-solaris2.*
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2016-10-18 13:04:42 UTC
When trying to compile gdb 7.12 on Solaris (tried 10 and 12), it fails in a 
couple of ways as initially reported at

https://sourceware.org/ml/gdb-patches/2016-10/msg00448.html:

In file included from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:0:
/vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:630:33: error: 'double atof(const char*)' conflicts with a previous declaration
 extern double atof (const char *); /* X3.159-1989  4.10.1.1 */
                                 ^
In file included from /usr/include/stdlib.h:17:0,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/common/common-defs.h:32,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:
/vol/gcc-4.9/lib/gcc/i386-pc-solaris2.10/4.9.0/include-fixed/iso/stdlib_iso.h:119:15: note: previous declaration 'double std::atof(const char*)'
 extern double atof(const char *);
               ^

  due to this gem in gdb/defs.h:

#ifndef atof
extern double atof (const char *);	/* X3.159-1989  4.10.1.1 */
#endif

/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'ptid_t procfs_wait(target_ops*, ptid_t, target_waitstatus*, int)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:3839:25: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
       status->value.sig = 0;
                         ^

In file included from /vol/src/gnu/gdb/gdb-7.12/gdb/common/common-defs.h:64:0,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:23:
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'void procfs_create_inferior(target_ops*, char*, char*, char**, int)':
/vol/src/gnu/gdb/gdb-7.12/gdb/../include/libiberty.h:722:38: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
 # define alloca(x) __builtin_alloca(x)
                                      ^
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:4570:17: note: in expansion of macro 'alloca'
       tryname = alloca (strlen (path) + strlen (shell_file) + 2);
                 ^

  add char * cast
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'int procfs_corefile_thread_callback(procinfo*, procinfo*, void*)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:5370:46: error: invalid conversion from 'void*' to 'procfs_corefile_thread_data*' [-fpermissive]
   struct procfs_corefile_thread_data *args = data;


/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'void do_destroy_procinfo_cleanup(void*)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:794:23: error: invalid conversion from 'void*' to 'procinfo*' [-fpermissive]
   destroy_procinfo (pi);
                       ^
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:772:1: note: initializing argument 1 of 'void destroy_procinfo(procinfo*)'
 destroy_procinfo (procinfo *pi)
 ^
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'sysset_t* sysset_t_alloc(procinfo*)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:848:22: error: invalid conversion from 'void*' to 'sysset_t*' [-fpermissive]
   ret = xmalloc (size);
                      ^
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'int proc_set_traced_sysentry(procinfo*, sysset_t*)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:1678:30: error: invalid conversion from 'void*' to 'proc_set_traced_sysentry(procinfo*, sysset_t*)::gdb_proc_ctl_pcsentry*' [-fpermissive]
     argp = xmalloc (argp_size);
                              ^
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'int proc_set_traced_sysexit(procinfo*, sysset_t*)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:1723:30: error: invalid conversion from 'void*' to 'proc_set_traced_sysexit(procinfo*, sysset_t*)::gdb_proc_ctl_pcsexit*' [-fpermissive]
     argp = xmalloc (argp_size);
                              ^
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c: In function 'void do_closedir_cleanup(void*)':
/vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:2759:16: error: invalid conversion from 'void*' to 'DIR*' [-fpermissive]
   closedir (dir);
                ^
In file included from build-gnulib/import/dirent.h:27:0,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/procfs.c:91:
/usr/include/dirent.h:103:13: note: initializing argument 1 of 'int closedir(DIR*)'
 extern int  closedir(DIR *);
             ^

/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c: In function 'ps_err_e ps_pdread(gdb_ps_prochandle_t, gdb_ps_addr_t, gdb_ps_read_buf_t, gdb_ps_size_t)':
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:821:43: error: invalid conversion from 'gdb_ps_read_buf_t {aka void*}' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
   return rw_common (0, ph, addr, buf, size);
                                           ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:780:1: note: initializing argument 4 of 'ps_err_e rw_common(int, const ps_prochandle*, gdb_ps_addr_t, gdb_byte*, int)'
 rw_common (int dowrite, const struct ps_prochandle *ph, gdb_ps_addr_t addr,
 ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c: In function 'ps_err_e ps_ptread(gdb_ps_prochandle_t, gdb_ps_addr_t, gdb_ps_read_buf_t, gdb_ps_size_t)':
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:839:43: error: invalid conversion from 'gdb_ps_read_buf_t {aka void*}' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
   return rw_common (0, ph, addr, buf, size);
                                           ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:780:1: note: initializing argument 4 of 'ps_err_e rw_common(int, const ps_prochandle*, gdb_ps_addr_t, gdb_byte*, int)'
 rw_common (int dowrite, const struct ps_prochandle *ph, gdb_ps_addr_t addr,
 ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c: In function 'void _initialize_sol_thread()':
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'void (*)(int)' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1255:3: note: in expansion of macro 'resolve'
   resolve (td_log);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const ps_prochandle*, td_thragent_t**) {aka td_err_e (*)(const ps_prochandle*, td_thragent**)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1256:3: note: in expansion of macro 'resolve'
   resolve (td_ta_new);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(td_thragent_t*) {aka td_err_e (*)(td_thragent*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1257:3: note: in expansion of macro 'resolve'
   resolve (td_ta_delete);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)()' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1258:3: note: in expansion of macro 'resolve'
   resolve (td_init);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thragent_t*, ps_prochandle**) {aka td_err_e (*)(const td_thragent*, ps_prochandle**)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1259:3: note: in expansion of macro 'resolve'
   resolve (td_ta_get_ph);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thragent_t*, int*) {aka td_err_e (*)(const td_thragent*, int*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1260:3: note: in expansion of macro 'resolve'
   resolve (td_ta_get_nthreads);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thragent_t*, int (*)(thread_key_t, void (*)(), void*), void*) {aka td_err_e (*)(const td_thragent*, int (*)(unsigned int, void (*)(), void*), void*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1261:3: note: in expansion of macro 'resolve'
   resolve (td_ta_tsd_iter);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thragent_t*, int (*)(const td_thrhandle_t*, void*), void*, td_thr_state_e, int, sigset_t*, unsigned int) {aka td_err_e (*)(const td_thragent*, int (*)(const td_thrhandle*, void*), void*, td_thr_state_e, int, sigset_t*, unsigned int)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1262:3: note: in expansion of macro 'resolve'
   resolve (td_ta_thr_iter);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*) {aka td_err_e (*)(const td_thrhandle*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1263:3: note: in expansion of macro 'resolve'
   resolve (td_thr_validate);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, thread_key_t, void**) {aka td_err_e (*)(const td_thrhandle*, unsigned int, void**)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1264:3: note: in expansion of macro 'resolve'
   resolve (td_thr_tsd);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, td_thrinfo_t*) {aka td_err_e (*)(const td_thrhandle*, td_thrinfo*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1265:3: note: in expansion of macro 'resolve'
   resolve (td_thr_get_info);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, fpregset_t*) {aka td_err_e (*)(const td_thrhandle*, fpu*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1266:3: note: in expansion of macro 'resolve'
   resolve (td_thr_getfpregs);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, int*) {aka td_err_e (*)(const td_thrhandle*, int*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1267:3: note: in expansion of macro 'resolve'
   resolve (td_thr_getxregsize);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, caddr_t) {aka td_err_e (*)(const td_thrhandle*, char*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1268:3: note: in expansion of macro 'resolve'
   resolve (td_thr_getxregs);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, sigset_t) {aka td_err_e (*)(const td_thrhandle*, sigset_t)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1269:3: note: in expansion of macro 'resolve'
   resolve (td_thr_sigsetmask);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, int) {aka td_err_e (*)(const td_thrhandle*, int)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1270:3: note: in expansion of macro 'resolve'
   resolve (td_thr_setprio);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, uchar_t, sigset_t) {aka td_err_e (*)(const td_thrhandle*, unsigned char, sigset_t)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1271:3: note: in expansion of macro 'resolve'
   resolve (td_thr_setsigpending);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, const fpregset_t*) {aka td_err_e (*)(const td_thrhandle*, const fpu*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1272:3: note: in expansion of macro 'resolve'
   resolve (td_thr_setfpregs);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, caddr_t) {aka td_err_e (*)(const td_thrhandle*, char*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1273:3: note: in expansion of macro 'resolve'
   resolve (td_thr_setxregs);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thragent_t*, thread_t, td_thrhandle_t*) {aka td_err_e (*)(const td_thragent*, unsigned int, td_thrhandle*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1274:3: note: in expansion of macro 'resolve'
   resolve (td_ta_map_id2thr);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thragent_t*, lwpid_t, td_thrhandle_t*) {aka td_err_e (*)(const td_thragent*, unsigned int, td_thrhandle*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1275:3: note: in expansion of macro 'resolve'
   resolve (td_ta_map_lwp2thr);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, greg_t*) {aka td_err_e (*)(const td_thrhandle*, int*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1276:3: note: in expansion of macro 'resolve'
   resolve (td_thr_getgregs);
   ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'td_err_e (*)(const td_thrhandle_t*, const greg_t*) {aka td_err_e (*)(const td_thrhandle*, const int*)}' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1277:3: note: in expansion of macro 'resolve'
   resolve (td_thr_setgregs);
   ^

When -Werror is enabled, there's also

/vol/src/gnu/gdb/gdb/local/gdb/procfs.c: In function 'ssd* proc_get_LDT_entry(procinfo*, int)':
/vol/src/gnu/gdb/gdb/local/gdb/procfs.c:2487:19: error: variable 'old_chain' set but not used [-Werror=unused-but-set-variable]
   struct cleanup *old_chain = NULL;
                   ^
and for a 32-bit compilation (which requires --disable-largefile to avoid

In file included from /usr/include/sys/procfs.h:28:0,
                 from /vol/src/gnu/gdb/gdb/local/gdb/i386-sol2-nat.c:23:
/usr/include/sys/old_procfs.h:39:2: error: #error "Cannot use procfs in the large file compilation environment"
 #error "Cannot use procfs in the large file compilation environment"
  ^
) we also get

/vol/src/gnu/gdb/gdb/local/gdb/top.c: In function 'void gdb_safe_append_history()':
/vol/src/gnu/gdb/gdb/local/gdb/top.c:1170:59: error: format '%d' expects argument of type 'int', but argument 3 has type 'pid_t {aka long int}' [-Werror=format=]
     = xstrprintf ("%s-gdb%d~", history_filename, getpid ());
                                                           ^

The posted patch and its follow-up fix all those.

  Rainer
Comment 1 cvs-commit@gcc.gnu.org 2016-10-25 13:22:54 UTC
The master branch has been updated by Rainer Orth <ro@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b196bc4cb45969ade48efcba6c31b1de0acf24d0

commit b196bc4cb45969ade48efcba6c31b1de0acf24d0
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue Oct 25 15:19:46 2016 +0200

    Fix gdb C++ compilation on Solaris (PR build/20712)
    
    gdb 7.12 doesn't compile as C++ (tried with g++ 4.9) on Solaris (tried
    10 and 12, sparc and x86).  The following patch (relative to the 7.12
    release, though I expect most if not all issues to be present on trunk,
    too) fixes this.
    
    Only a few of the changes bear explanation:
    
    * Initially, compilation failed whereever defs.h. was included:
    
    In file included from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:0:
    /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:630:33: error: 'double atof(const char*)' conflicts with a previous declaration
     extern double atof (const char *); /* X3.159-1989  4.10.1.1 */
                                     ^
    In file included from /usr/include/stdlib.h:17:0,
                     from build-gnulib/import/stdlib.h:36,
                     from /vol/src/gnu/gdb/gdb-7.12/gdb/common/common-defs.h:32,
                     from /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:28,
                     from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:
    /vol/gcc-4.9/lib/gcc/i386-pc-solaris2.10/4.9.0/include-fixed/iso/stdlib_iso.h:119:15: note: previous declaration 'double std::atof(const char*)'
     extern double atof(const char *);
                   ^
    
      This is due to this gem in gdb/defs.h which seems to have been present
      like forever:
    
    #ifndef atof
    extern double atof (const char *);	/* X3.159-1989  4.10.1.1 */
    #endif
    
      In the Solaris headers, the appropriate functions are in namespace std,
      thus the conflict.  I've wrapped the defs.h declaration in !__cplusplus
      to avoid this; perhaps it can go completely instead.
    
    * All the casts are necessary to appease g++ and should be pretty
      obvious.
    
    * The sol-thread.c changes are here to handle
    
    /vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c: In function 'void _initialize_sol_thread()':
    /vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'void (*)(int)' [-fpermissive]
       if (!(p_##X = dlsym (dlhandle, #X))) \
                                        ^
    /vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1255:3: note: in expansion of macro 'resolve'
       resolve (td_log);
       ^
    
      and are modeled after linux-thread-db.c (try_thread_db_load_1).
    
    The patch allowed both 32 and 64-bit C++ builds on sparc-sun-solaris2.10
    and i386-pc-solaris2.10 to complete.  The resulting binary hasn't seen
    more than a smoke test (invoke it on itself, b main, run) yet.
    
    When investigating the failure to detect -static-libstdc++
    support (more below), I found two more issues which only show up with
    -Werror:
    
    /vol/src/gnu/gdb/gdb/local/gdb/procfs.c: In function 'ssd* proc_get_LDT_entry(procinfo*, int)':
    /vol/src/gnu/gdb/gdb/local/gdb/procfs.c:2487:19: error: variable 'old_chain' set but not used [-Werror=unused-but-set-variable]
       struct cleanup *old_chain = NULL;
                       ^
    
    Unless I'm mistaken, you need to run do_cleanups on every return from
    the function.
    
    Afterwards, I ran a 32-bit compilation, which (after adding
    --disable-largefile to avoid
    
    In file included from /usr/include/sys/procfs.h:28:0,
                     from /vol/src/gnu/gdb/gdb/local/gdb/i386-sol2-nat.c:23:
    /usr/include/sys/old_procfs.h:39:2: error: #error "Cannot use procfs in the large file compilation environment"
     #error "Cannot use procfs in the large file compilation environment"
      ^
    
    and two more instances) revealed
    
    /vol/src/gnu/gdb/gdb/local/gdb/top.c: In function 'void gdb_safe_append_history()':
    /vol/src/gnu/gdb/gdb/local/gdb/top.c:1170:59: error: format '%d' expects argument of type 'int', but argument 3 has type 'pid_t {aka long int}' [-Werror=format=]
         = xstrprintf ("%s-gdb%d~", history_filename, getpid ());
                                                               ^
    
    Fixed by casting pid_t to long and printing it as such.
Comment 2 cvs-commit@gcc.gnu.org 2016-10-25 13:55:16 UTC
The gdb-7.12-branch branch has been updated by Rainer Orth <ro@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fd5c8f0002f6790d57b6479bc9f2e86ccd63a68b

commit fd5c8f0002f6790d57b6479bc9f2e86ccd63a68b
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue Oct 25 15:51:40 2016 +0200

    Fix gdb C++ compilation on Solaris (PR build/20712)
    
    gdb 7.12 doesn't compile as C++ (tried with g++ 4.9) on Solaris (tried
    10 and 12, sparc and x86).  The following patch (relative to the 7.12
    release, though I expect most if not all issues to be present on trunk,
    too) fixes this.
    
    Only a few of the changes bear explanation:
    
    * Initially, compilation failed whereever defs.h. was included:
    
    In file included from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:0:
    /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:630:33: error: 'double atof(const char*)' conflicts with a previous declaration
     extern double atof (const char *); /* X3.159-1989  4.10.1.1 */
                                     ^
    In file included from /usr/include/stdlib.h:17:0,
                     from build-gnulib/import/stdlib.h:36,
                     from /vol/src/gnu/gdb/gdb-7.12/gdb/common/common-defs.h:32,
                     from /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:28,
                     from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:
    /vol/gcc-4.9/lib/gcc/i386-pc-solaris2.10/4.9.0/include-fixed/iso/stdlib_iso.h:119:15: note: previous declaration 'double std::atof(const char*)'
     extern double atof(const char *);
                   ^
    
      This is due to this gem in gdb/defs.h which seems to have been present
      like forever:
    
    #ifndef atof
    extern double atof (const char *);	/* X3.159-1989  4.10.1.1 */
    #endif
    
      In the Solaris headers, the appropriate functions are in namespace std,
      thus the conflict.  I've wrapped the defs.h declaration in !__cplusplus
      to avoid this; perhaps it can go completely instead.
    
    * All the casts are necessary to appease g++ and should be pretty
      obvious.
    
    * The sol-thread.c changes are here to handle
    
    /vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c: In function 'void _initialize_sol_thread()':
    /vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'void (*)(int)' [-fpermissive]
       if (!(p_##X = dlsym (dlhandle, #X))) \
                                        ^
    /vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1255:3: note: in expansion of macro 'resolve'
       resolve (td_log);
       ^
    
      and are modeled after linux-thread-db.c (try_thread_db_load_1).
    
    The patch allowed both 32 and 64-bit C++ builds on sparc-sun-solaris2.10
    and i386-pc-solaris2.10 to complete.  The resulting binary hasn't seen
    more than a smoke test (invoke it on itself, b main, run) yet.
    
    When investigating the failure to detect -static-libstdc++
    support (more below), I found two more issues which only show up with
    -Werror:
    
    /vol/src/gnu/gdb/gdb/local/gdb/procfs.c: In function 'ssd* proc_get_LDT_entry(procinfo*, int)':
    /vol/src/gnu/gdb/gdb/local/gdb/procfs.c:2487:19: error: variable 'old_chain' set but not used [-Werror=unused-but-set-variable]
       struct cleanup *old_chain = NULL;
                       ^
    
    Unless I'm mistaken, you need to run do_cleanups on every return from
    the function.
    
    Afterwards, I ran a 32-bit compilation, which (after adding
    --disable-largefile to avoid
    
    In file included from /usr/include/sys/procfs.h:28:0,
                     from /vol/src/gnu/gdb/gdb/local/gdb/i386-sol2-nat.c:23:
    /usr/include/sys/old_procfs.h:39:2: error: #error "Cannot use procfs in the large file compilation environment"
     #error "Cannot use procfs in the large file compilation environment"
      ^
    
    and two more instances) revealed
    
    /vol/src/gnu/gdb/gdb/local/gdb/top.c: In function 'void gdb_safe_append_history()':
    /vol/src/gnu/gdb/gdb/local/gdb/top.c:1170:59: error: format '%d' expects argument of type 'int', but argument 3 has type 'pid_t {aka long int}' [-Werror=format=]
         = xstrprintf ("%s-gdb%d~", history_filename, getpid ());
                                                               ^
    
    Fixed by casting pid_t to long and printing it as such.
Comment 3 Joel Brobecker 2016-10-25 17:04:05 UTC
Is this issue fixed? If yes, let's close. If not, should we  update the 7.12.1 release wiki page (https://sourceware.org/gdb/wiki/GDB_7.12_Release) to make sure we tell the users exactly what got fixed by the 7.12.1 release?
Comment 4 Pedro Alves 2016-10-25 21:22:54 UTC
Rainer, I've given your account editbugs privileges now (meaning, you can close now bugs).

> If not, should we  update the 7.12.1 release wiki page (https://sourceware.org/gdb/wiki/GDB_7.12_Release) to make sure we tell the users
> exactly what got fixed by the 7.12.1 release?

Is the target milestone marker sufficient?  It's much more convenient to only have to update this info in one place.
Comment 5 Pedro Alves 2016-10-25 21:24:20 UTC
Ignore that question, I understand what you meant now...  I think this is fully fixed now.  But I'd like to give Rainer a chance to try his new privileges.
Comment 6 Rainer Orth 2016-10-26 08:08:10 UTC
Fixed for 7.12.1, 7.13.
Comment 7 Rainer Orth 2016-10-26 08:11:06 UTC
> --- Comment #3 from Joel Brobecker <brobecker at gnat dot com> ---
> Is this issue fixed? If yes, let's close. If not, should we  update the 7.12.1
> release wiki page (https://sourceware.org/gdb/wiki/GDB_7.12_Release) to make
> sure we tell the users exactly what got fixed by the 7.12.1 release?

Just closed.  Btw, the PROBLEMS link on https://sourceware.org/gdb/
still points to the long-obsolete cvsweb.  This should be updated
appropriately.

	Rainer
Comment 8 Joel Brobecker 2016-10-26 12:34:34 UTC
> Btw, the PROBLEMS link on https://sourceware.org/gdb/
> still points to the long-obsolete cvsweb.  This should be updated
> appropriately.

ooops, that's true. I fixed the website.

That made me realize that the PROBLEMS file still lists GDB 7.2.50 as
the version number. That's something that should be done during the release process, so something on me. It's all script-based, so I will work on automating that part sometime next week.