aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-04-09 04:36:51 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-04-09 04:36:51 +0000
commit3fa176b767e14e1d2491775978afac3e87892d1d (patch)
tree35478f4f4ff092374f748479debcda06b96dd6dd
parentad7d66abe909d867c032019b18a4ef20f22af368 (diff)
downloadgcc-3fa176b767e14e1d2491775978afac3e87892d1d.zip
gcc-3fa176b767e14e1d2491775978afac3e87892d1d.tar.gz
gcc-3fa176b767e14e1d2491775978afac3e87892d1d.tar.bz2
compiler: sort packages in export data more deterministically
We can have multiple packages with the same name, so also sort by pkgpath. To avoid an inconsistent sort, sort by symbol and pointer address if we somehow get two different packages with the same name and pkgpath. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/171032 From-SVN: r270220
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/export.cc19
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 1e4da03..74e811b 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-a69f7c05f1880bb90544fb0c3577109cb1d7f3ab
+8822487ed776d55eafed44de7d89ee54bbfbab47
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc
index 963f0bf..066455a 100644
--- a/gcc/go/gofrontend/export.cc
+++ b/gcc/go/gofrontend/export.cc
@@ -509,7 +509,24 @@ Export::set_type_index(Type* type)
static bool
packages_compare(const Package* a, const Package* b)
{
- return a->package_name() < b->package_name();
+ if (a->package_name() < b->package_name())
+ return true;
+ else if (a->package_name() > b->package_name())
+ return false;
+
+ if (a->pkgpath() < b->pkgpath())
+ return true;
+ else if (a->pkgpath() > b->pkgpath())
+ return false;
+
+ // In principle if we get here then a == b. Try to do something sensible
+ // even if the import information is inconsistent.
+ if (a->pkgpath_symbol() < b->pkgpath_symbol())
+ return true;
+ else if (a->pkgpath_symbol() > b->pkgpath_symbol())
+ return false;
+
+ return a < b;
}
// Write out all the known packages whose pkgpath symbol is not a