Commit ac819ba5 by Ian Lance Taylor Committed by Ian Lance Taylor

re PR other/46789 (go configuration with --prefix=/usr pollutes the /usr/lib namespace)

	PR other/46789
	PR bootstrap/46812
	* go-lang.c (go_char_p): Define type and vectors.
	(go_search_dirs): New static variable.
	(go_langhook_handle_option): Use version and version/machine
	directories for -L.
	(go_langhook_post_options): Add non-specific -L paths.
	* Make-lang.in (go/go-lang.o): Define DEFAULT_TARGET_VERSION and
	DEFAULT_TARGET_MACHINE when compiling.
	* gccgo.texi (Invoking gccgo): Only document -L for linking.
	(Import and Export): Don't mention -L for finding import files.

libgo: Install .gox files in version and target specific directory.

From-SVN: r167537
parent 501c95ff
2010-12-06 Ian Lance Taylor <iant@google.com>
PR other/46789
PR bootstrap/46812
* go-lang.c (go_char_p): Define type and vectors.
(go_search_dirs): New static variable.
(go_langhook_handle_option): Use version and version/machine
directories for -L.
(go_langhook_post_options): Add non-specific -L paths.
* Make-lang.in (go/go-lang.o): Define DEFAULT_TARGET_VERSION and
DEFAULT_TARGET_MACHINE when compiling.
* gccgo.texi (Invoking gccgo): Only document -L for linking.
(Import and Export): Don't mention -L for finding import files.
2010-12-03 Ian Lance Taylor <iant@google.com> 2010-12-03 Ian Lance Taylor <iant@google.com>
PR bootstrap/46776 PR bootstrap/46776
......
...@@ -218,10 +218,16 @@ GO_IMPORT_H = go/gofrontend/import.h go/gofrontend/export.h ...@@ -218,10 +218,16 @@ GO_IMPORT_H = go/gofrontend/import.h go/gofrontend/export.h
go/go-backend.o: go/go-backend.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ go/go-backend.o: go/go-backend.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TREE_H) $(TM_H) $(TM_P_H) $(TREE_H) $(TM_H) $(TM_P_H)
go/go-lang.o: go/go-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(OPTS_H) \ go/go-lang.o: go/go-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(OPTS_H) \
$(TREE_H) $(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h \ $(TREE_H) $(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h \
$(FLAGS_H) convert.h $(DIAGNOSTIC_H) langhooks.h $(LANGHOOKS_DEF_H) \ $(FLAGS_H) convert.h $(DIAGNOSTIC_H) langhooks.h \
$(EXCEPT_H) $(TARGET_H) $(GO_C_H) gt-go-go-lang.h gtype-go.h $(LANGHOOKS_DEF_H) $(EXCEPT_H) $(TARGET_H) $(GO_C_H) \
gt-go-go-lang.h gtype-go.h
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
-DDEFAULT_TARGET_VERSION=\"$(version)\" \
-DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\" \
-c $< $(OUTPUT_OPTION)
GOINCLUDES = -I $(srcdir)/go -I $(srcdir)/go/gofrontend GOINCLUDES = -I $(srcdir)/go -I $(srcdir)/go/gofrontend
......
...@@ -154,8 +154,8 @@ compile time. ...@@ -154,8 +154,8 @@ compile time.
@item -L@var{dir} @item -L@var{dir}
@cindex @option{-L} @cindex @option{-L}
When compiling, synonymous with @option{-I}. When linking, specify a When linking, specify a library search directory, as with
library search directory, as with @command{gcc}. @command{gcc}.
@item -fgo-prefix=@var{string} @item -fgo-prefix=@var{string}
@cindex @option{-fgo-prefix} @cindex @option{-fgo-prefix}
...@@ -198,11 +198,10 @@ first one that it finds. ...@@ -198,11 +198,10 @@ first one that it finds.
@end table @end table
The compiler will search for these files in the directories named by The compiler will search for these files in the directories named by
any @option{-I} or @option{-L} options, in order in which the any @option{-I} options, in order in which the directories appear on
directories appear on the command line. The compiler will then search the command line. The compiler will then search several standard
several standard system directories. Finally the compiler will search system directories. Finally the compiler will search the current
the current directory (to search the current directory earlier, use directory (to search the current directory earlier, use @samp{-I.}).
@samp{-I.}).
The compiler will extract the export information directly from the The compiler will extract the export information directly from the
compiled object file. The file @file{@var{gopackage}.gox} will compiled object file. The file @file{@var{gopackage}.gox} will
......
...@@ -162,6 +162,17 @@ go_langhook_init_options_struct (struct gcc_options *opts) ...@@ -162,6 +162,17 @@ go_langhook_init_options_struct (struct gcc_options *opts)
opts->x_flag_non_call_exceptions = 1; opts->x_flag_non_call_exceptions = 1;
} }
/* Infrastructure for a VEC of char * pointers. */
typedef const char *go_char_p;
DEF_VEC_P(go_char_p);
DEF_VEC_ALLOC_P(go_char_p, heap);
/* The list of directories to search after all the Go specific
directories have been searched. */
static VEC(go_char_p, heap) *go_search_dirs;
/* Handle Go specific options. Return 0 if we didn't do anything. */ /* Handle Go specific options. Return 0 if we didn't do anything. */
static bool static bool
...@@ -179,13 +190,47 @@ go_langhook_handle_option ( ...@@ -179,13 +190,47 @@ go_langhook_handle_option (
switch (code) switch (code)
{ {
case OPT_I: case OPT_I:
case OPT_L:
/* For the compiler, we currently handle -I and -L exactly the
same way: they give us a directory to search for import
statements. */
go_add_search_path (arg); go_add_search_path (arg);
break; break;
case OPT_L:
/* A -L option is assumed to come from the compiler driver.
This is a system directory. We search the following
directories, if they exist, before this one:
dir/go/VERSION
dir/go/VERSION/MACHINE
This is like include/c++. */
{
static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
size_t len;
char *p;
struct stat st;
len = strlen (arg);
p = XALLOCAVEC (char,
(len + sizeof "go" + sizeof DEFAULT_TARGET_VERSION
+ sizeof DEFAULT_TARGET_MACHINE + 3));
strcpy (p, arg);
if (len > 0 && !IS_DIR_SEPARATOR (p[len - 1]))
strcat (p, dir_separator_str);
strcat (p, "go");
strcat (p, dir_separator_str);
strcat (p, DEFAULT_TARGET_VERSION);
if (stat (p, &st) == 0 && S_ISDIR (st.st_mode))
{
go_add_search_path (p);
strcat (p, dir_separator_str);
strcat (p, DEFAULT_TARGET_MACHINE);
if (stat (p, &st) == 0 && S_ISDIR (st.st_mode))
go_add_search_path (p);
}
/* Search ARG too, but only after we've searched to Go
specific directories for all -L arguments. */
VEC_safe_push (go_char_p, heap, go_search_dirs, arg);
}
break;
case OPT_fgo_dump_: case OPT_fgo_dump_:
ret = go_enable_dump (arg) ? true : false; ret = go_enable_dump (arg) ? true : false;
break; break;
...@@ -207,8 +252,16 @@ go_langhook_handle_option ( ...@@ -207,8 +252,16 @@ go_langhook_handle_option (
static bool static bool
go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED) go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
{ {
unsigned int ix;
const char *dir;
gcc_assert (num_in_fnames > 0); gcc_assert (num_in_fnames > 0);
FOR_EACH_VEC_ELT (go_char_p, go_search_dirs, ix, dir)
go_add_search_path (dir);
VEC_free (go_char_p, heap, go_search_dirs);
go_search_dirs = NULL;
if (flag_excess_precision_cmdline == EXCESS_PRECISION_DEFAULT) if (flag_excess_precision_cmdline == EXCESS_PRECISION_DEFAULT)
flag_excess_precision_cmdline = EXCESS_PRECISION_STANDARD; flag_excess_precision_cmdline = EXCESS_PRECISION_STANDARD;
......
...@@ -15,6 +15,8 @@ endif ...@@ -15,6 +15,8 @@ endif
SUBDIRS = ${subdirs} SUBDIRS = ${subdirs}
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
MAINT_CHARSET = latin1 MAINT_CHARSET = latin1
mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
...@@ -95,7 +97,9 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) ...@@ -95,7 +97,9 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
toolexeclib_LTLIBRARIES = libgo.la toolexeclib_LTLIBRARIES = libgo.la
toolexeclib_LIBRARIES = libgobegin.a toolexeclib_LIBRARIES = libgobegin.a
toolexeclib_DATA = \ toolexeclibgodir = $(toolexeclibdir)/go/$(gcc_version)/$(target_alias)
toolexeclibgo_DATA = \
asn1.gox \ asn1.gox \
big.gox \ big.gox \
bufio.gox \ bufio.gox \
...@@ -145,30 +149,30 @@ toolexeclib_DATA = \ ...@@ -145,30 +149,30 @@ toolexeclib_DATA = \
websocket.gox \ websocket.gox \
xml.gox xml.gox
toolexeclibarchivedir = $(toolexeclibdir)/archive toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
toolexeclibarchive_DATA = \ toolexeclibgoarchive_DATA = \
archive/tar.gox \ archive/tar.gox \
archive/zip.gox archive/zip.gox
toolexeclibcompressdir = $(toolexeclibdir)/compress toolexeclibgocompressdir = $(toolexeclibgodir)/compress
toolexeclibcompress_DATA = \ toolexeclibgocompress_DATA = \
compress/flate.gox \ compress/flate.gox \
compress/gzip.gox \ compress/gzip.gox \
compress/zlib.gox compress/zlib.gox
toolexeclibcontainerdir = $(toolexeclibdir)/container toolexeclibgocontainerdir = $(toolexeclibgodir)/container
toolexeclibcontainer_DATA = \ toolexeclibgocontainer_DATA = \
container/heap.gox \ container/heap.gox \
container/list.gox \ container/list.gox \
container/ring.gox \ container/ring.gox \
container/vector.gox container/vector.gox
toolexeclibcryptodir = $(toolexeclibdir)/crypto toolexeclibgocryptodir = $(toolexeclibgodir)/crypto
toolexeclibcrypto_DATA = \ toolexeclibgocrypto_DATA = \
crypto/aes.gox \ crypto/aes.gox \
crypto/block.gox \ crypto/block.gox \
crypto/blowfish.gox \ crypto/blowfish.gox \
...@@ -189,9 +193,9 @@ toolexeclibcrypto_DATA = \ ...@@ -189,9 +193,9 @@ toolexeclibcrypto_DATA = \
crypto/x509.gox \ crypto/x509.gox \
crypto/xtea.gox crypto/xtea.gox
toolexeclibdebugdir = $(toolexeclibdir)/debug toolexeclibgodebugdir = $(toolexeclibgodir)/debug
toolexeclibdebug_DATA = \ toolexeclibgodebug_DATA = \
debug/dwarf.gox \ debug/dwarf.gox \
debug/elf.gox \ debug/elf.gox \
debug/gosym.gox \ debug/gosym.gox \
...@@ -199,9 +203,9 @@ toolexeclibdebug_DATA = \ ...@@ -199,9 +203,9 @@ toolexeclibdebug_DATA = \
debug/pe.gox \ debug/pe.gox \
debug/proc.gox debug/proc.gox
toolexeclibencodingdir = $(toolexeclibdir)/encoding toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
toolexeclibencoding_DATA = \ toolexeclibgoencoding_DATA = \
encoding/ascii85.gox \ encoding/ascii85.gox \
encoding/base64.gox \ encoding/base64.gox \
encoding/binary.gox \ encoding/binary.gox \
...@@ -209,16 +213,16 @@ toolexeclibencoding_DATA = \ ...@@ -209,16 +213,16 @@ toolexeclibencoding_DATA = \
encoding/hex.gox \ encoding/hex.gox \
encoding/pem.gox encoding/pem.gox
toolexeclibexpdir = $(toolexeclibdir)/exp toolexeclibgoexpdir = $(toolexeclibgodir)/exp
toolexeclibexp_DATA = \ toolexeclibgoexp_DATA = \
exp/datafmt.gox \ exp/datafmt.gox \
exp/draw.gox \ exp/draw.gox \
exp/eval.gox exp/eval.gox
toolexeclibgodir = $(toolexeclibdir)/go toolexeclibgogodir = $(toolexeclibgodir)/go
toolexeclibgo_DATA = \ toolexeclibgogo_DATA = \
go/ast.gox \ go/ast.gox \
go/doc.gox \ go/doc.gox \
go/parser.gox \ go/parser.gox \
...@@ -227,63 +231,63 @@ toolexeclibgo_DATA = \ ...@@ -227,63 +231,63 @@ toolexeclibgo_DATA = \
go/token.gox \ go/token.gox \
go/typechecker.gox go/typechecker.gox
toolexeclibhashdir = $(toolexeclibdir)/hash toolexeclibgohashdir = $(toolexeclibgodir)/hash
toolexeclibhash_DATA = \ toolexeclibgohash_DATA = \
hash/adler32.gox \ hash/adler32.gox \
hash/crc32.gox \ hash/crc32.gox \
hash/crc64.gox hash/crc64.gox
toolexeclibhttpdir = $(toolexeclibdir)/http toolexeclibgohttpdir = $(toolexeclibgodir)/http
toolexeclibhttp_DATA = \ toolexeclibgohttp_DATA = \
http/pprof.gox http/pprof.gox
toolexeclibimagedir = $(toolexeclibdir)/image toolexeclibgoimagedir = $(toolexeclibgodir)/image
toolexeclibimage_DATA = \ toolexeclibgoimage_DATA = \
image/jpeg.gox \ image/jpeg.gox \
image/png.gox image/png.gox
toolexeclibindexdir = $(toolexeclibdir)/index toolexeclibgoindexdir = $(toolexeclibgodir)/index
toolexeclibindex_DATA = \ toolexeclibgoindex_DATA = \
index/suffixarray.gox index/suffixarray.gox
toolexeclibiodir = $(toolexeclibdir)/io toolexeclibgoiodir = $(toolexeclibgodir)/io
toolexeclibio_DATA = \ toolexeclibgoio_DATA = \
io/ioutil.gox io/ioutil.gox
toolexeclibmimedir = $(toolexeclibdir)/mime toolexeclibgomimedir = $(toolexeclibgodir)/mime
toolexeclibmime_DATA = \ toolexeclibgomime_DATA = \
mime/multipart.gox mime/multipart.gox
toolexeclibnetdir = $(toolexeclibdir)/net toolexeclibgonetdir = $(toolexeclibgodir)/net
toolexeclibnet_DATA = \ toolexeclibgonet_DATA = \
net/dict.gox \ net/dict.gox \
net/textproto.gox net/textproto.gox
toolexeclibosdir = $(toolexeclibdir)/os toolexeclibgoosdir = $(toolexeclibgodir)/os
toolexeclibos_DATA = \ toolexeclibgoos_DATA = \
os/signal.gox os/signal.gox
toolexeclibrpcdir = $(toolexeclibdir)/rpc toolexeclibgorpcdir = $(toolexeclibgodir)/rpc
toolexeclibrpc_DATA = \ toolexeclibgorpc_DATA = \
rpc/jsonrpc.gox rpc/jsonrpc.gox
toolexeclibruntimedir = $(toolexeclibdir)/runtime toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
toolexeclibruntime_DATA = \ toolexeclibgoruntime_DATA = \
runtime/pprof.gox runtime/pprof.gox
toolexeclibtestingdir = $(toolexeclibdir)/testing toolexeclibgotestingdir = $(toolexeclibgodir)/testing
toolexeclibtesting_DATA = \ toolexeclibgotesting_DATA = \
testing/iotest.gox \ testing/iotest.gox \
testing/quick.gox \ testing/quick.gox \
testing/script.gox testing/script.gox
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment