Re: Go patch committed: Rationalize external symbol names
On Thu, Jan 25, 2018 at 12:50 PM, Rainer Orthwrote: > >> From the error messages I guess the problem is that the assembler >> doesn't like symbols that start with ".1". Do you know what names the >> assembler permits? > > The x86 Assembly Language Reference Manual states: Thanks. Looking back, it was actually not my plan to have symbols that start with '.'. It was a bug, fixed by this patch. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE === --- gcc/go/gofrontend/MERGE (revision 257061) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -553e04735d1be372c596c720bcaea27e050b13a6 +203cbe7d3820fa03c965a01f72461f71588fe952 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/go-encode-id.cc === --- gcc/go/gofrontend/go-encode-id.cc (revision 257033) +++ gcc/go/gofrontend/go-encode-id.cc (working copy) @@ -104,6 +104,14 @@ go_encode_id(const std::string ) std::string ret; const char* p = id.c_str(); const char* pend = p + id.length(); + + // A leading ".0" is a space introduced before a mangled type name + // that starts with a 'u' or 'U', to avoid confusion with the + // mangling used here. We don't need a leading ".0", and we don't + // want symbols that start with '.', so remove it. + if (p[0] == '.' && p[1] == '0') +p += 2; + while (p < pend) { unsigned int c; @@ -115,16 +123,19 @@ go_encode_id(const std::string ) go_assert(!char_needs_encoding(c)); ret += c; } - else if (c < 0x1) - { - char buf[16]; - snprintf(buf, sizeof buf, "..u%04x", c); - ret += buf; - } else { char buf[16]; - snprintf(buf, sizeof buf, "..U%08x", c); + if (c < 0x1) + snprintf(buf, sizeof buf, "..u%04x", c); + else + snprintf(buf, sizeof buf, "..U%08x", c); + + // We don't want a symbol to start with '.', so add a prefix + // if needed. + if (ret.empty()) + ret += '_'; + ret += buf; } p += len; Index: gcc/go/gofrontend/names.cc === --- gcc/go/gofrontend/names.cc (revision 257033) +++ gcc/go/gofrontend/names.cc (working copy) @@ -213,7 +213,7 @@ Gogo::function_asm_name(const std::strin { std::string ret; if (rtype != NULL) -ret = rtype->mangled_name(this); +ret = rtype->deref()->mangled_name(this); else if (package == NULL) ret = this->pkgpath_symbol(); else @@ -892,14 +892,7 @@ Named_type::append_mangled_type_name(Gog const Typed_identifier* rcvr = this->in_function_->func_value()->type()->receiver(); if (rcvr != NULL) - { - std::string m = rcvr->type()->mangled_name(gogo); - // Turn a leading ".1" back into "*" since we are going - // to type-mangle this name again. - if (m.compare(0, 2, ".1") == 0) - m = "*" + m.substr(2); - ret->append(m); - } + ret->append(rcvr->type()->deref()->mangled_name(gogo)); else if (this->in_function_->package() == NULL) ret->append(gogo->pkgpath_symbol()); else @@ -956,7 +949,7 @@ Gogo::type_descriptor_name(Type* type, N const Typed_identifier* rcvr = in_function->func_value()->type()->receiver(); if (rcvr != NULL) - ret.append(rcvr->type()->mangled_name(this)); + ret.append(rcvr->type()->deref()->mangled_name(this)); else if (in_function->package() == NULL) ret.append(this->pkgpath_symbol()); else Index: libgo/testsuite/gotest === --- libgo/testsuite/gotest (revision 256593) +++ libgo/testsuite/gotest (working copy) @@ -518,7 +518,7 @@ localname() { pattern='Test([^a-z].*)?' # The -p option tells GNU nm not to sort. # The -v option tells Solaris nm to sort by value. - tests=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | $symtogo) + tests=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | $symtogo) if [ "x$tests" = x ]; then echo 'gotest: warning: no tests matching '$pattern in _gotest_.o $xofile 1>&2 exit 2 Index: libgo/go/runtime/pprof/pprof_test.go === --- libgo/go/runtime/pprof/pprof_test.go
Re: Go patch committed: Rationalize external symbol names
Hi Ian, > From the error messages I guess the problem is that the assembler > doesn't like symbols that start with ".1". Do you know what names the > assembler permits? The x86 Assembly Language Reference Manual states: 2.1.2.1 Identifiers An identifier is an arbitrarily-long sequence of letters and digits. The first character must be a letter; the underscore (_) (ASCII 0x5F) and the period (.) (ASCII 0x2E) are considered to be letters. Case is significant: uppercase and lowercase letters are different. Contrary to that, /bin/as won't assemble .globl .1 The SPARC Assembly Language Reference Manual states this instead: 1.3.6 Symbol Names The syntax for a symbol name is: { letter | _ | $ | . } { letter | _ | $ | . | digit }* In the above syntax: * Uppercase and lowercase letters are distinct; the underscore ( _ ), dollar sign ($), and dot ( . ) are treated as alphabetic characters. * Symbol names that begin with a dot ( . ) are assumed to be local symbols. To simplify debugging, avoid using this type of symbol name in hand-coded assembly language routines. * The symbol dot ( . ) is predefined and always refers to the address of the beginning of the current assembly language statement. * External variable names beginning with the underscore character are reserved by the ANSI C Standard. Do not begin these names with the underscore; otherwise, the program will not conform to ANSI C and unpredictable behavior may result. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: Go patch committed: Rationalize external symbol names
On Thu, Jan 25, 2018 at 12:40:13PM -0800, Ian Lance Taylor wrote: > >> Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed > >> to mainline. > > > > this patch almost certainly (i.e. I didn't reghunt, but it's the only > > plausible candidate between r257023 and r257057) Solaris/x86 bootstrap > > with /bin/as: > > > > Assembler: doc.go > > "/var/tmp//ccbyjwCc.s", line 1043 : Syntax error > > Near line: ".globl .1fmt.fmt.clearflags" > > "/var/tmp//ccbyjwCc.s", line 1044 : Syntax error > > Near line: ".type .1fmt.fmt.clearflags, @function" > > "/var/tmp//ccbyjwCc.s", line 1045 : Illegal mnemonic > > Near line: ".1fmt.fmt.clearflags:" > > "/var/tmp//ccbyjwCc.s", line 1045 : Syntax error > > Near line: ".1fmt.fmt.clearflags:" > > "/var/tmp//ccbyjwCc.s", line 1045 : Syntax error > > Near line: ".1fmt.fmt.clearflags:" > > "/var/tmp//ccbyjwCc.s", line 1058 : Syntax error > > Near line: ".size .1fmt.fmt.clearflags, > > .-.1fmt.fmt.clearflags" > > "/var/tmp//ccbyjwCc.s", line 1060 : Syntax error > > Near line: ".globl .1fmt.pp.Width" > > "/var/tmp//ccbyjwCc.s", line 1061 : Syntax error > > Near line: ".type .1fmt.pp.Width, @function" > > "/var/tmp//ccbyjwCc.s", line 1062 : Illegal mnemonic > > Near line: ".1fmt.pp.Width:" > > "/var/tmp//ccbyjwCc.s", line 1062 : Syntax error > > Near line: ".1fmt.pp.Width:" > > "/var/tmp//ccbyjwCc.s", line 1062 : Syntax error > > Near line: ".1fmt.pp.Width:" > > "/var/tmp//ccbyjwCc.s", line 1082 : Syntax error > > Near line: ".size .1fmt.pp.Width, .-.1fmt.pp.Width" > > "/var/tmp//ccbyjwCc.s", line 1084 : Syntax error > > Near line: ".globl .1fmt.pp.Precision" > > "/var/tmp//ccbyjwCc.s", line 1085 : Syntax error > > Near line: ".type .1fmt.pp.Precision, @function" > > "/var/tmp//ccbyjwCc.s", line 1086 : Illegal mnemonic > > Near line: ".1fmt.pp.Precision:" > > "/var/tmp//ccbyjwCc.s", line 1086 : Syntax error > > Near line: ".1fmt.pp.Precision:" > > "/var/tmp//ccbyjwCc.s", line 1086 : Syntax error > > Near line: ".1fmt.pp.Precision:" > > "/var/tmp//ccbyjwCc.s", line 1106 : Syntax error > > Near line: ".size .1fmt.pp.Precision, .-.1fmt.pp.Precision" > > "/var/tmp//ccbyjwCc.s", line 1108 : Syntax error > > Near line: ".globl .1fmt.ss.Width" > > "/var/tmp//ccbyjwCc.s", line 1109 : Syntax error > > Near line: ".type .1fmt.ss.Width, @function" > > "/var/tmp//ccbyjwCc.s", line 1110 : Illegal mnemonic > > Near line: ".1fmt.ss.Width:" > > "/var/tmp//ccbyjwCc.s", line 1110 : Syntax error > > Near line: ".1fmt.ss.Width:" > > "/var/tmp//ccbyjwCc.s", line 1110 : Syntax error > > Near line: ".1fmt.ss.Width:" > > "/var/tmp//ccbyjwCc.s", line 1149 : Syntax error > > Near line: ".size .1fmt.ss.Width, .-.1fmt.ss.Width" > > "/var/tmp//ccbyjwCc.s", line 1151 : Syntax error > > Near line: ".globl .1fmt.ss.UnreadRune" > > "/var/tmp//ccbyjwCc.s", line 1152 : Syntax error > > Near line: ".type .1fmt.ss.UnreadRune, @function" > > "/var/tmp//ccbyjwCc.s", line 1153 : Illegal mnemonic > > Near line: ".1fmt.ss.UnreadRune:" > > "/var/tmp//ccbyjwCc.s", line 1153 : Syntax error > > Near line: ".1fmt.ss.UnreadRune:" > > "/var/tmp//ccbyjwCc.s", line 1153 : Syntax error > > Near line: ".1fmt.ss.UnreadRune:" > > "/var/tmp//ccbyjwCc.s", line 1209 : Syntax error > > Near line: ".size .1fmt.ss.UnreadRune, .-.1fmt.ss.UnreadRune" > > "/var/tmp//ccbyjwCc.s", line 1908 : Syntax error > > Near line: ".globl .1fmt.fmt.init" > > Too many errors - Goodbye > > make[4]: *** [Makefile:3322: fmt.lo] Error 1 > > > > Solaris/SPARC with /bin/as is fine, but that's not too astonishing since > > both assemblers are mostly different code bases. > > >From the error messages I guess the problem is that the assembler > doesn't like symbols that start with ".1". Do you know what names the > assembler permits? It isn't just Solaris/SPARC, I saw bootstrap failure with go on powerpc64-linux and powerpc64le-linux too, similar errors. /tmp/cc9hDRO7.s: Assembler messages: /tmp/cc9hDRO7.s:128: Error: symbol `.1errors.errorString.Error' is already defined /tmp/cc9hDRO7.s: Error: .size expression for .1errors.errorString.Error does not evaluate to a constant /home/jakub/gcc/obj22/gotools/../../gotools/../libgo/go/cmd/vet/unsafeptr.go:60: undefined reference to `.1go_types.Package.Path' /home/jakub/gcc/obj22/gotools/../../gotools/../libgo/go/cmd/vet/unsafeptr.go:61: undefined reference to `.1go_types.Named.Obj'
Re: Go patch committed: Rationalize external symbol names
On Thu, Jan 25, 2018 at 12:28 PM, Rainer Orthwrote: > >> This patch to the Go frontend rationalizes the external symbol names >> that appear in assembler code. It changes from the ad hoc mechanisms >> used to date to produce a set of names that are at least somewhat more >> coherent. They are also more readable, after applying a simple >> demangling algorithms outlined in the long comment in names.cc. The >> new names use only ASCII alphanumeric characters, underscore, and dot >> (which fixes AIX by avoiding the use of dollar sign). If we really >> had to we could replace dot with underscore at the cost of forbidding >> some uses of underscore in Go identifier names. >> >> A minor cleanup discovered during this was that we were treating >> function types as different if one had a NULL parameters_ field and >> another has a non-NULL parameters_ field that has no parameters. This >> worked because we mangled them slightly differently. We now mangle >> them the same, so we treat them as equal, as we should anyhow. >> >> Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed >> to mainline. > > this patch almost certainly (i.e. I didn't reghunt, but it's the only > plausible candidate between r257023 and r257057) Solaris/x86 bootstrap > with /bin/as: > > Assembler: doc.go > "/var/tmp//ccbyjwCc.s", line 1043 : Syntax error > Near line: ".globl .1fmt.fmt.clearflags" > "/var/tmp//ccbyjwCc.s", line 1044 : Syntax error > Near line: ".type .1fmt.fmt.clearflags, @function" > "/var/tmp//ccbyjwCc.s", line 1045 : Illegal mnemonic > Near line: ".1fmt.fmt.clearflags:" > "/var/tmp//ccbyjwCc.s", line 1045 : Syntax error > Near line: ".1fmt.fmt.clearflags:" > "/var/tmp//ccbyjwCc.s", line 1045 : Syntax error > Near line: ".1fmt.fmt.clearflags:" > "/var/tmp//ccbyjwCc.s", line 1058 : Syntax error > Near line: ".size .1fmt.fmt.clearflags, .-.1fmt.fmt.clearflags" > "/var/tmp//ccbyjwCc.s", line 1060 : Syntax error > Near line: ".globl .1fmt.pp.Width" > "/var/tmp//ccbyjwCc.s", line 1061 : Syntax error > Near line: ".type .1fmt.pp.Width, @function" > "/var/tmp//ccbyjwCc.s", line 1062 : Illegal mnemonic > Near line: ".1fmt.pp.Width:" > "/var/tmp//ccbyjwCc.s", line 1062 : Syntax error > Near line: ".1fmt.pp.Width:" > "/var/tmp//ccbyjwCc.s", line 1062 : Syntax error > Near line: ".1fmt.pp.Width:" > "/var/tmp//ccbyjwCc.s", line 1082 : Syntax error > Near line: ".size .1fmt.pp.Width, .-.1fmt.pp.Width" > "/var/tmp//ccbyjwCc.s", line 1084 : Syntax error > Near line: ".globl .1fmt.pp.Precision" > "/var/tmp//ccbyjwCc.s", line 1085 : Syntax error > Near line: ".type .1fmt.pp.Precision, @function" > "/var/tmp//ccbyjwCc.s", line 1086 : Illegal mnemonic > Near line: ".1fmt.pp.Precision:" > "/var/tmp//ccbyjwCc.s", line 1086 : Syntax error > Near line: ".1fmt.pp.Precision:" > "/var/tmp//ccbyjwCc.s", line 1086 : Syntax error > Near line: ".1fmt.pp.Precision:" > "/var/tmp//ccbyjwCc.s", line 1106 : Syntax error > Near line: ".size .1fmt.pp.Precision, .-.1fmt.pp.Precision" > "/var/tmp//ccbyjwCc.s", line 1108 : Syntax error > Near line: ".globl .1fmt.ss.Width" > "/var/tmp//ccbyjwCc.s", line 1109 : Syntax error > Near line: ".type .1fmt.ss.Width, @function" > "/var/tmp//ccbyjwCc.s", line 1110 : Illegal mnemonic > Near line: ".1fmt.ss.Width:" > "/var/tmp//ccbyjwCc.s", line 1110 : Syntax error > Near line: ".1fmt.ss.Width:" > "/var/tmp//ccbyjwCc.s", line 1110 : Syntax error > Near line: ".1fmt.ss.Width:" > "/var/tmp//ccbyjwCc.s", line 1149 : Syntax error > Near line: ".size .1fmt.ss.Width, .-.1fmt.ss.Width" > "/var/tmp//ccbyjwCc.s", line 1151 : Syntax error > Near line: ".globl .1fmt.ss.UnreadRune" > "/var/tmp//ccbyjwCc.s", line 1152 : Syntax error > Near line: ".type .1fmt.ss.UnreadRune, @function" > "/var/tmp//ccbyjwCc.s", line 1153 : Illegal mnemonic > Near line: ".1fmt.ss.UnreadRune:" > "/var/tmp//ccbyjwCc.s", line 1153 : Syntax error > Near line: ".1fmt.ss.UnreadRune:" > "/var/tmp//ccbyjwCc.s", line 1153 : Syntax error > Near line: ".1fmt.ss.UnreadRune:" > "/var/tmp//ccbyjwCc.s", line 1209 : Syntax error > Near line: ".size .1fmt.ss.UnreadRune, .-.1fmt.ss.UnreadRune" > "/var/tmp//ccbyjwCc.s", line 1908 : Syntax error > Near line: ".globl .1fmt.fmt.init" > Too many errors - Goodbye > make[4]: *** [Makefile:3322: fmt.lo] Error 1 > > Solaris/SPARC with /bin/as is fine, but that's not too astonishing since > both assemblers
Re: Go patch committed: Rationalize external symbol names
Hi Ian, > This patch to the Go frontend rationalizes the external symbol names > that appear in assembler code. It changes from the ad hoc mechanisms > used to date to produce a set of names that are at least somewhat more > coherent. They are also more readable, after applying a simple > demangling algorithms outlined in the long comment in names.cc. The > new names use only ASCII alphanumeric characters, underscore, and dot > (which fixes AIX by avoiding the use of dollar sign). If we really > had to we could replace dot with underscore at the cost of forbidding > some uses of underscore in Go identifier names. > > A minor cleanup discovered during this was that we were treating > function types as different if one had a NULL parameters_ field and > another has a non-NULL parameters_ field that has no parameters. This > worked because we mangled them slightly differently. We now mangle > them the same, so we treat them as equal, as we should anyhow. > > Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed > to mainline. this patch almost certainly (i.e. I didn't reghunt, but it's the only plausible candidate between r257023 and r257057) Solaris/x86 bootstrap with /bin/as: Assembler: doc.go "/var/tmp//ccbyjwCc.s", line 1043 : Syntax error Near line: ".globl .1fmt.fmt.clearflags" "/var/tmp//ccbyjwCc.s", line 1044 : Syntax error Near line: ".type .1fmt.fmt.clearflags, @function" "/var/tmp//ccbyjwCc.s", line 1045 : Illegal mnemonic Near line: ".1fmt.fmt.clearflags:" "/var/tmp//ccbyjwCc.s", line 1045 : Syntax error Near line: ".1fmt.fmt.clearflags:" "/var/tmp//ccbyjwCc.s", line 1045 : Syntax error Near line: ".1fmt.fmt.clearflags:" "/var/tmp//ccbyjwCc.s", line 1058 : Syntax error Near line: ".size .1fmt.fmt.clearflags, .-.1fmt.fmt.clearflags" "/var/tmp//ccbyjwCc.s", line 1060 : Syntax error Near line: ".globl .1fmt.pp.Width" "/var/tmp//ccbyjwCc.s", line 1061 : Syntax error Near line: ".type .1fmt.pp.Width, @function" "/var/tmp//ccbyjwCc.s", line 1062 : Illegal mnemonic Near line: ".1fmt.pp.Width:" "/var/tmp//ccbyjwCc.s", line 1062 : Syntax error Near line: ".1fmt.pp.Width:" "/var/tmp//ccbyjwCc.s", line 1062 : Syntax error Near line: ".1fmt.pp.Width:" "/var/tmp//ccbyjwCc.s", line 1082 : Syntax error Near line: ".size .1fmt.pp.Width, .-.1fmt.pp.Width" "/var/tmp//ccbyjwCc.s", line 1084 : Syntax error Near line: ".globl .1fmt.pp.Precision" "/var/tmp//ccbyjwCc.s", line 1085 : Syntax error Near line: ".type .1fmt.pp.Precision, @function" "/var/tmp//ccbyjwCc.s", line 1086 : Illegal mnemonic Near line: ".1fmt.pp.Precision:" "/var/tmp//ccbyjwCc.s", line 1086 : Syntax error Near line: ".1fmt.pp.Precision:" "/var/tmp//ccbyjwCc.s", line 1086 : Syntax error Near line: ".1fmt.pp.Precision:" "/var/tmp//ccbyjwCc.s", line 1106 : Syntax error Near line: ".size .1fmt.pp.Precision, .-.1fmt.pp.Precision" "/var/tmp//ccbyjwCc.s", line 1108 : Syntax error Near line: ".globl .1fmt.ss.Width" "/var/tmp//ccbyjwCc.s", line 1109 : Syntax error Near line: ".type .1fmt.ss.Width, @function" "/var/tmp//ccbyjwCc.s", line 1110 : Illegal mnemonic Near line: ".1fmt.ss.Width:" "/var/tmp//ccbyjwCc.s", line 1110 : Syntax error Near line: ".1fmt.ss.Width:" "/var/tmp//ccbyjwCc.s", line 1110 : Syntax error Near line: ".1fmt.ss.Width:" "/var/tmp//ccbyjwCc.s", line 1149 : Syntax error Near line: ".size .1fmt.ss.Width, .-.1fmt.ss.Width" "/var/tmp//ccbyjwCc.s", line 1151 : Syntax error Near line: ".globl .1fmt.ss.UnreadRune" "/var/tmp//ccbyjwCc.s", line 1152 : Syntax error Near line: ".type .1fmt.ss.UnreadRune, @function" "/var/tmp//ccbyjwCc.s", line 1153 : Illegal mnemonic Near line: ".1fmt.ss.UnreadRune:" "/var/tmp//ccbyjwCc.s", line 1153 : Syntax error Near line: ".1fmt.ss.UnreadRune:" "/var/tmp//ccbyjwCc.s", line 1153 : Syntax error Near line: ".1fmt.ss.UnreadRune:" "/var/tmp//ccbyjwCc.s", line 1209 : Syntax error Near line: ".size .1fmt.ss.UnreadRune, .-.1fmt.ss.UnreadRune" "/var/tmp//ccbyjwCc.s", line 1908 : Syntax error Near line: ".globl .1fmt.fmt.init" Too many errors - Goodbye make[4]: *** [Makefile:3322: fmt.lo] Error 1 Solaris/SPARC with /bin/as is fine, but that's not too astonishing since both assemblers are mostly different code bases. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Go patch committed: Rationalize external symbol names
This patch to the Go frontend rationalizes the external symbol names that appear in assembler code. It changes from the ad hoc mechanisms used to date to produce a set of names that are at least somewhat more coherent. They are also more readable, after applying a simple demangling algorithms outlined in the long comment in names.cc. The new names use only ASCII alphanumeric characters, underscore, and dot (which fixes AIX by avoiding the use of dollar sign). If we really had to we could replace dot with underscore at the cost of forbidding some uses of underscore in Go identifier names. A minor cleanup discovered during this was that we were treating function types as different if one had a NULL parameters_ field and another has a non-NULL parameters_ field that has no parameters. This worked because we mangled them slightly differently. We now mangle them the same, so we treat them as equal, as we should anyhow. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 2018-01-24 Ian Lance Taylor* go.go-torture/execute/names-1.go: New test. Index: gcc/go/gofrontend/MERGE === --- gcc/go/gofrontend/MERGE (revision 256971) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -3488a401e50835de5de5c4f153772ac2798d0e71 +0bbc03f81c862fb35be3edee9824698a7892a17e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/escape.cc === --- gcc/go/gofrontend/escape.cc (revision 256835) +++ gcc/go/gofrontend/escape.cc (working copy) @@ -686,42 +686,33 @@ debug_function_name(Named_object* fn) if (!fn->is_function()) return Gogo::unpack_hidden_name(fn->name()); - if (fn->func_value()->enclosing() == NULL) + + std::string fnname = Gogo::unpack_hidden_name(fn->name()); + if (fn->func_value()->is_method()) { - std::string fnname = Gogo::unpack_hidden_name(fn->name()); - if (fn->func_value()->is_method()) -{ - // Methods in gc compiler are named "T.m" or "(*T).m" where - // T is the receiver type. Add the receiver here. - Type* rt = fn->func_value()->type()->receiver()->type(); - switch (rt->classification()) -{ - case Type::TYPE_NAMED: -fnname = rt->named_type()->name() + "." + fnname; -break; - - case Type::TYPE_POINTER: -{ - Named_type* nt = rt->points_to()->named_type(); - if (nt != NULL) -fnname = "(*" + nt->name() + ")." + fnname; - break; -} - - default: -break; -} -} - return fnname; + // Methods in gc compiler are named "T.m" or "(*T).m" where + // T is the receiver type. Add the receiver here. + Type* rt = fn->func_value()->type()->receiver()->type(); + switch (rt->classification()) + { + case Type::TYPE_NAMED: + fnname = rt->named_type()->name() + "." + fnname; + break; + + case Type::TYPE_POINTER: + { + Named_type* nt = rt->points_to()->named_type(); + if (nt != NULL) + fnname = "(*" + nt->name() + ")." + fnname; + break; + } + + default: + break; + } } - // Closures are named ".$nested#" where # is a global counter. Add outer - // function name for better distinguishing. This is also closer to what - // gc compiler prints, "outer.func#". - Named_object* enclosing = fn->func_value()->enclosing(); - std::string name = Gogo::unpack_hidden_name(fn->name()); - std::string outer_name = Gogo::unpack_hidden_name(enclosing->name()); - return outer_name + "." + name; + return fnname; } // Return the name of the current function. Index: gcc/go/gofrontend/expressions.cc === --- gcc/go/gofrontend/expressions.cc(revision 256835) +++ gcc/go/gofrontend/expressions.cc(working copy) @@ -1310,6 +1310,16 @@ Func_descriptor_expression::do_get_backe && Linemap::is_predeclared_location(no->location())) is_descriptor = true; + // The runtime package implements some functions defined in the + // syscall package. Let the syscall package define the descriptor + // in this case. + if (gogo->compiling_runtime() + && gogo->package_name() == "runtime" + && no->is_function() + && !no->func_value()->asm_name().empty() + && no->func_value()->asm_name().compare(0, 8, "syscall.") == 0) +is_descriptor = true; + Btype* btype = this->type()->get_backend(gogo); Bvariable* bvar; @@ -6845,7 +6855,8 @@ Bound_method_expression::create_thunk(Go if (orig_fntype == NULL || !orig_fntype->is_method()) {