From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3705 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: C++ ABI TODO list Date: Mon, 22 Jul 2013 11:45:51 -0400 Message-ID: <20130722154551.GI3249@brightrain.aerifal.cx> References: <20130720052614.GA17733@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw" X-Trace: ger.gmane.org 1374507965 17320 80.91.229.3 (22 Jul 2013 15:46:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Jul 2013 15:46:05 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3709-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 22 17:46:06 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1V1IJK-0000Eh-9m for gllmg-musl@plane.gmane.org; Mon, 22 Jul 2013 17:46:06 +0200 Original-Received: (qmail 6102 invoked by uid 550); 22 Jul 2013 15:46:05 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 6091 invoked from network); 22 Jul 2013 15:46:05 -0000 Content-Disposition: inline In-Reply-To: <20130720052614.GA17733@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:3705 Archived-At: --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Jul 20, 2013 at 01:26:14AM -0400, Rich Felker wrote: > Here are the changes I'm aware of that would be needed to bring musl's > C++ ABI in line with glibc/LSB, enabling C++ library reuse with musl: > [...] > > I'm hoping the above list is all... It wasn't. I've just committed the first patch for this agenda item, massively refactoring the headers, reducing the dependency on the alltypes system where it's not really needed, moving most of the arch-generic types to a shared alltypes file, and fixing the low-hanging fruit for ABI compatibility. The reason these changes were committed together rather than either without the other is: - Fixing ABI compatibility first would have been ugly when the same type was scattered across multiple archs' alltypes files. - Refactoring without fixing at least some of the low-hanging ABI issues would have meant gratuitously writing new alltypes.h.in files with the wrong types, only to rewrite them immediately in the next commit. The remaining differences from glibc: - fd_mask signedness - glibc is wrong; their definition invokes UB when used in the headers. I believe they're actually fixing the type on their end anyway) - jmp_buf and sigjmp_buf - fixing this requires changing the underlying types to be the same, as discussed before, and is a much more functional change than I wanted in this patch. - pthread_*attr_t - despite just being single integers, glibc has these wrapped in structures; changing musl to match will require some minor code changes. - regex_t - glibc's struct tag violates the namespace. we could change it just in C++ mode, though... - regoff_t - glibc's definition is wrong; it's too short on 64-bit archs. but we could fix it on 32-bit archs. - wint_t - glibc has wint_t defined as unsigned int on all archs (actually it defers to gcc if gcc defines it, but gcc also defines it as unsigned int on at least all current archs). since this is an actual arithmetic type, not an opaque type like dev_t, I felt that changing it as part of this commit would be too much of a functional change. also I need to review whether any code in musl assumes it's signed. So this comes down to only 3-4 changes left to make, each of which have some impact on the code (either change or just review for correctness). In other words, the C++ ABI compatibility goal is almost done. For those interested, I'm attaching the C++ ABI check tool I've been using. It's based on the type sizes check code from nsz's musl tools repo, but with the macros changed (and hacked up a bit to remove irrelevant types) to output C++ code that gets the compiler to do the desired name mangling. The intended usage is: g++ abi.cxx nm abi.o | sed s/^.*check_// | sort Then you can diff the outputs from different libcs/compilers to check for compatibility and get a report of which types differ. Rich --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="abi.cxx" #define _GNU_SOURCE 1 #define _LARGEFILE64_SOURCE 1 #define _FILE_OFFSET_BITS 64 #define SYSLOG_NAMES 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include #include //#include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define p(x) void check_##x##____ (x dummy) { } #define q(x) void check_ptr_##x##____ (x * dummy) { } #define s(x) void check_struct_##x##____ (struct x dummy) { } q(DIR) p(Dl_info) q(FILE) p(blkcnt_t) p(blksize_t) p(caddr_t) p(cc_t) p(clock_t) p(clockid_t) p(comp_t) p(dev_t) p(div_t) p(double) p(double_t) p(fd_mask) p(fd_set) p(fenv_t) p(fexcept_t) p(float) p(float_t) p(fpos_t) p(fsblkcnt_t) p(fsfilcnt_t) p(fsid_t) p(gid_t) p(glob_t) p(iconv_t) p(id_t) p(idtype_t) p(imaxdiv_t) p(in_addr_t) p(in_port_t) p(ino_t) p(int) p(int16_t) p(int32_t) p(int64_t) p(int8_t) p(int_fast16_t) p(int_fast32_t) p(int_fast64_t) p(int_fast8_t) p(int_least16_t) p(int_least32_t) p(int_least64_t) p(int_least8_t) p(intmax_t) p(intptr_t) p(jmp_buf) p(key_t) p(ldiv_t) p(lldiv_t) p(locale_t) p(lwpid_t) p(mbstate_t) p(mcontext_t) p(mode_t) p(mqd_t) p(msglen_t) p(msgqnum_t) p(n_long) p(n_short) p(n_time) p(nfds_t) p(nl_catd) p(nl_item) p(nlink_t) p(off_t) p(pid_t) p(posix_spawn_file_actions_t) p(posix_spawnattr_t) p(prfpregset_t) p(prgregset_t) p(prpsinfo_t) p(prstatus_t) p(psaddr_t) p(pthread_attr_t) p(pthread_barrier_t) p(pthread_barrierattr_t) p(pthread_cond_t) p(pthread_condattr_t) p(pthread_key_t) p(pthread_mutex_t) p(pthread_mutexattr_t) p(pthread_once_t) p(pthread_rwlock_t) p(pthread_rwlockattr_t) p(pthread_spinlock_t) p(pthread_t) p(ptrdiff_t) p(quad_t) p(regex_t) p(register_t) p(regmatch_t) p(regoff_t) p(rlim_t) p(sa_family_t) p(sem_t) p(sig_atomic_t) p(sig_t) p(sighandler_t) p(siginfo_t) p(sigjmp_buf) p(sigset_t) p(size_t) p(socklen_t) p(speed_t) p(ssize_t) p(stack_t) s(FTW) s(acct) s(acct_v3) s(addrinfo) s(aiocb) s(ar_hdr) s(arpd_request) s(arphdr) s(arpreq) s(arpreq_old) s(bandinfo) s(ccs_modesel_head) s(cmsghdr) s(crypt_data) s(dirent) s(dl_phdr_info) s(elf_prpsinfo) s(elf_prstatus) s(elf_siginfo) s(epoll_event) s(ether_addr) s(ether_arp) s(ether_header) s(ethhdr) s(f_owner_ex) s(flock) s(group) s(hostent) s(icmp) s(icmp6_filter) s(icmp6_hdr) s(icmp6_router_renum) s(icmp_ra_addr) s(icmphdr) s(if_nameindex) s(ifaddr) s(ifconf) s(ifmap) s(ifreq) s(in_addr) s(in_pktinfo) s(inotify_event) s(iovec) s(ip) s(ip_mreq) s(ip_mreqn) s(ip_opts) s(ip_timestamp) s(ipc_perm) s(iphdr) s(ipv6_mreq) s(itimerspec) s(itimerval) s(lastlog) s(lconv) s(linger) s(link_map) s(mld_hdr) s(mntent) s(mq_attr) s(msgbuf) s(msghdr) s(msginfo) s(msqid_ds) s(mt_tape_info) s(mtconfiginfo) s(mtget) s(mtop) s(mtpos) s(netent) s(ntptimeval) s(option) s(packet_mreq) s(passwd) s(pollfd) s(protoent) s(qelem) s(r_debug) s(res_sym) s(rlimit) s(rr_pco_match) s(rr_pco_use) s(rr_result) s(rtentry) s(rusage) s(sched_param) s(sembuf) s(semid_ds) s(seminfo) s(servent) s(sg_header) s(sg_io_hdr) s(sg_iovec) s(sg_req_info) s(sg_scsi_id) s(shm_info) s(shmid_ds) s(shminfo) s(sigaction) s(sigcontext) s(sigevent) s(signalfd_siginfo) s(sockaddr) s(sockaddr_in) s(sockaddr_in6) s(sockaddr_ll) s(sockaddr_storage) s(sockaddr_un) s(spwd) s(stat) s(statfs) s(statvfs) s(str_list) s(str_mlist) s(strbuf) s(strfdinsert) s(strioctl) s(strpeek) s(strrecvfd) s(termios) s(timespec) s(timestamp) s(timeval) s(timex) s(tm) s(tms) s(ucred) s(udphdr) s(user) s(utimbuf) s(utmpx) s(utsname) s(winsize) p(suseconds_t) p(tcflag_t) p(time_t) p(timer_t) p(u_char) p(u_int) p(u_int16_t) p(u_int32_t) p(u_int64_t) p(u_int8_t) p(u_long) p(u_quad_t) p(u_short) p(ucontext_t) p(uid_t) p(uint) p(uint16_t) p(uint32_t) p(uint64_t) p(uint8_t) p(uint_fast16_t) p(uint_fast32_t) p(uint_fast64_t) p(uint_fast8_t) p(uint_least16_t) p(uint_least32_t) p(uint_least64_t) p(uint_least8_t) p(uintmax_t) p(uintptr_t) p(ulong) //p(union sigval) p(ushort) p(va_list) p(wchar_t) p(wctrans_t) p(wctype_t) p(wint_t) p(wordexp_t) --wac7ysb48OaltWcw--