public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: java-prs@gcc.gnu.org Subject: [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ) Date: Mon, 17 May 2010 12:54:00 -0000 [thread overview] Message-ID: <20100517125401.19509.qmail@sourceware.org> (raw) In-Reply-To: <bug-38812-17178@http.gcc.gnu.org/bugzilla/> ------- Comment #5 from fxcoudert at gcc dot gnu dot org 2010-05-17 12:53 ------- On Mac OS X (all versions), the correct fix is to use _NSGetEnviron() instead of extern variable environ, and to include <crt_externs.h>. Example of use: #include <stdlib.h> #include <string.h> #include <crt_externs.h> int main (void) { // Instead of: extern char **environ; #define environ (*_NSGetEnviron()) char **env = malloc (3 * sizeof(char *)); env[0] = strdup ("VAR1=this is variable one"); env[1] = strdup ("PATH=/dev/null"); env[2] = NULL; environ = env; system ("/usr/bin/env"); return 0; } (see http://www.gnu.org/software/gnulib/manual/html_node/environ.html) So, a possible patch (protecting target-specific code with #idef's; I don't know if that's the style libjava maintainers would like best) is: Index: java/lang/natPosixProcess.cc =================================================================== --- java/lang/natPosixProcess.cc (revision 159481) +++ java/lang/natPosixProcess.cc (working copy) @@ -54,7 +54,12 @@ using gnu::java::nio::channels::FileChannelImpl; using namespace java::lang; +#ifdef __APPLE__ +#include <crt_externs.h> +#define environ (*_NSGetEnviron()) +#else extern char **environ; +#endif static char * new_string (jstring string) -- fxcoudert at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fxcoudert at gcc dot gnu dot | |org, tromey at redhat dot | |com, aph at redhat dot com Last reconfirmed|2009-01-13 01:03:10 |2010-05-17 12:53:59 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812
next prev parent reply other threads:[~2010-05-17 12:54 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-01-12 11:29 [Bug libgcj/38812] New: " pkeller at globalphasing dot com 2009-01-12 11:30 ` [Bug libgcj/38812] " pkeller at globalphasing dot com 2009-01-12 11:31 ` pkeller at globalphasing dot com 2009-01-13 1:03 ` pinskia at gcc dot gnu dot org 2009-01-13 11:26 ` pkeller at globalphasing dot com 2010-05-17 12:54 ` fxcoudert at gcc dot gnu dot org [this message] [not found] <bug-38812-8172@http.gcc.gnu.org/bugzilla/> 2015-06-11 0:16 ` egall at gwmail dot gwu.edu 2015-09-03 18:03 ` egall at gwmail dot gwu.edu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100517125401.19509.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=java-prs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).