public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
       [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
  1 sibling, 0 replies; 7+ messages in thread
From: egall at gwmail dot gwu.edu @ 2015-06-11  0:16 UTC (permalink / raw)
  To: java-prs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812

Eric Gallager <egall at gwmail dot gwu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egall at gwmail dot gwu.edu

--- Comment #6 from Eric Gallager <egall at gwmail dot gwu.edu> ---
There's also some places where environ is used as an extern variable in
libiberty that would need similar fixes; specifically in pex-unix.c and
xmalloc.c.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
       [not found] <bug-38812-8172@http.gcc.gnu.org/bugzilla/>
  2015-06-11  0:16 ` [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ) egall at gwmail dot gwu.edu
@ 2015-09-03 18:03 ` egall at gwmail dot gwu.edu
  1 sibling, 0 replies; 7+ messages in thread
From: egall at gwmail dot gwu.edu @ 2015-09-03 18:03 UTC (permalink / raw)
  To: java-prs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812

--- Comment #7 from Eric Gallager <egall at gwmail dot gwu.edu> ---
(In reply to Eric Gallager from comment #6)
> There's also some places where environ is used as an extern variable in
> libiberty that would need similar fixes; specifically in pex-unix.c and
> xmalloc.c.

...and it turns out that that is bug 63758, for reference... (sorry for the
digression; I hadn't seen the other one previously...)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
  2009-01-12 11:29 [Bug libgcj/38812] New: " pkeller at globalphasing dot com
                   ` (3 preceding siblings ...)
  2009-01-13 11:26 ` pkeller at globalphasing dot com
@ 2010-05-17 12:54 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2010-05-17 12:54 UTC (permalink / raw)
  To: java-prs



------- 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
  2009-01-12 11:29 [Bug libgcj/38812] New: " pkeller at globalphasing dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 7+ messages in thread
From: pkeller at globalphasing dot com @ 2009-01-13 11:26 UTC (permalink / raw)
  To: java-prs



------- Comment #4 from pkeller at globalphasing dot com  2009-01-13 11:26 -------
Thanks for confirming the problem. I know that what I did isn't particularly
portable (although it would be fine on the systems that I work with). I vaguely
remember something about setenv not being available on Solaris, but I haven't
worked with Solaris for several years now.

I'm hoping that someone with more experience than me of libgcj development and
the range of supported OS's can use my information to submit a more robust fix.
I'll keep an eye on this bug and help out if I can.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
  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
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-13  1:03 UTC (permalink / raw)
  To: java-prs



------- Comment #3 from pinskia at gcc dot gnu dot org  2009-01-13 01:03 -------
Confirmed, though your patch is not portable really.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|i386-apple-darwin9.5.0      |
   GCC host triplet|i386-apple-darwin9.5.0      |
 GCC target triplet|i386-apple-darwin9.5.0      |*-*-darwin*
   Last reconfirmed|0000-00-00 00:00:00         |2009-01-13 01:03:10
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: pkeller at globalphasing dot com @ 2009-01-12 11:31 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from pkeller at globalphasing dot com  2009-01-12 11:31 -------
Created an attachment (id=17076)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17076&action=view)
Preprocessor output


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ)
  2009-01-12 11:29 [Bug libgcj/38812] New: " pkeller at globalphasing dot com
@ 2009-01-12 11:30 ` pkeller at globalphasing dot com
  2009-01-12 11:31 ` pkeller at globalphasing dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: pkeller at globalphasing dot com @ 2009-01-12 11:30 UTC (permalink / raw)
  To: java-prs



------- Comment #1 from pkeller at globalphasing dot com  2009-01-12 11:30 -------
Created an attachment (id=17075)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17075&action=view)
Output from gcj -v


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38812


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-03 18:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-38812-8172@http.gcc.gnu.org/bugzilla/>
2015-06-11  0:16 ` [Bug libgcj/38812] gcj-built executables don't run after strip (libgcj erroneously references _environ) egall at gwmail dot gwu.edu
2015-09-03 18:03 ` egall at gwmail dot gwu.edu
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 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).