Project

General

Profile

Actions

Bug #2463

closed

__thread storage class for errno may break Firefox 17.0esr C++ compilation

Added by davshao almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
11/26/2012
Due date:
% Done:

0%

Estimated time:

Description

Executing the commands on the file cpperrno.cpp
$ c++ cpperrno.cpp
$ ./a.out
produces the output:
errno = 22
on NetBSD amd64, FreeBSD amd64, and Linux amd64 (Ubuntu 12.04 LTS).
However on DragonFly the output is an error message:
$ c++ cpperrno.cpp
/tmp//ccTk4OGn.o: In function `(anonymous namespace)::__error()':
cpperrno.cpp:(.text+0x10): undefined reference to `(anonymous namespace)::errno'

This matters because the file cpperrno.cpp is a minimal example demonstrating build breakage of current pkgsrc devel/xulrunner for Firefox 17.0esr, as reported in a followup to PR pkg/47233.

The difference appears to be that on DragonFly in file sys/sys/errno.h, there is the declaration:

#if !defined(_KERNEL) || defined(_KERNEL_VIRTUAL)
extern __thread int errno;

Obviously there are reasons to use storage class keyword __thread for errno; nonetheless, the breakage of compilation for Firefox 17.0esr on no platform but DragonFly indicates some alternative solution must be devised for porting C++ userland programs.

/* begin cpperrno.cpp */
namespace {

#pragma GCC visibility push(default)
#include <errno.h>
#pragma GCC visibility pop

void innamespace() {
errno = EINVAL;
}

} /* end namespace */

extern "C" {

void seterrno() {
innamespace();
}

} /* end extern */

#include <stdio.h>
#include <errno.h>

int main() {
seterrno();
printf("errno = %d\n", errno);
return errno;
}
/* end cpperrno.cpp */


Files

cpperrno.cpp (394 Bytes) cpperrno.cpp davshao, 11/26/2012 09:32 PM
Actions

Also available in: Atom PDF