• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for OS216


Commit MetaInfo

Revision374ee317356c39b6ac9d483b3648ffcb6f1d2fd4 (tree)
Time2020-06-05 13:00:51
AuthorGiuliano Belinassi <giuliano.belinassi@usp....>
CommiterGiuliano Belinassi

Log Message

Make libgcc compile

Finally, we managed to get libgcc to compile with this version.
Changes to the partitioner were necesary for this, such as
merging partitions with calls to static functions in common.

gcc/ChangeLog
2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br>

* cgraph.h (symtab_node): New attribute aux2.
* cgraphunit.c (ipa_passes): Decide not to compile in parallel.
* gcc.c (has_hidden_E): New function.
* (append_split_outputs): Add fPIC and abort when a hidden -E is
provided.
* (execute): Do not call append_split_outputs when -E is provided.
* lto-partition.c: Merge calls to static functions to same
partition.
* (lto_check_usage_from_other_partitions): Update
used_from_other_partitions to nodes other than varpool.

gcc/testsuite/ChangeLog
2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br>

* gcc.dg/driver/driver.exp: New test.
* gcc.dg/driver/empty.c: New file.

Change Summary

Incremental Difference

--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
1+2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br>
2+
3+ * cgraph.h (symtab_node): New attribute aux2.
4+ * cgraphunit.c (ipa_passes): Decide not to compile in parallel.
5+ * gcc.c (has_hidden_E): New function.
6+ * (append_split_outputs): Add fPIC and abort when a hidden -E is
7+ provided.
8+ * (execute): Do not call append_split_outputs when -E is provided.
9+ * lto-partition.c: Merge calls to static functions to same
10+ partition.
11+ * (lto_check_usage_from_other_partitions): Update
12+ used_from_other_partitions to nodes other than varpool.
13+
114 2020-06-04 Giuliano Belinassi <giuliano.belinassi@usp.br>
215
316 * lto-partition.c (class union_find): New class.
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -615,6 +615,7 @@ public:
615615 struct lto_file_decl_data * lto_file_data;
616616
617617 PTR GTY ((skip)) aux;
618+ int aux2;
618619
619620 /* Comdat group the symbol is in. Can be private if GGC allowed that. */
620621 tree x_comdat_group;
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2664,6 +2664,14 @@ ipa_passes (void)
26642664 FOR_EACH_SYMBOL (node)
26652665 node->aux = NULL;
26662666
2667+ /* We decided that partitioning is a bad idea. In this case, just
2668+ proceed with the default compilation method. */
2669+ if (ltrans_partitions.length () <= 1)
2670+ {
2671+ flag_wpa = NULL;
2672+ goto continue_compilation;
2673+ }
2674+
26672675 /* Find out statics that need to be promoted
26682676 to globals with hidden visibility because they are accessed from
26692677 multiple partitions. */
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3299,6 +3299,18 @@ static const char *get_path_to_ld (void)
32993299 return ret;
33003300 }
33013301
3302+/* Check if a hidden -E was passed as argument to something. */
3303+
3304+static bool has_hidden_E (int argc, const char *argv[])
3305+{
3306+ int i;
3307+ for (i = 0; i < argc; ++i)
3308+ if (!strcmp (argv[i], "-E"))
3309+ return true;
3310+
3311+ return false;
3312+}
3313+
33023314 /* Append -fsplit-output=<tempfile> to all calls to compilers. Return true
33033315 if a additional call to LD is required to merge the resulting files. */
33043316
@@ -3317,16 +3329,21 @@ static void append_split_outputs (extra_arg_storer *storer,
33173329
33183330 if (is_compiler (commands[0].prog))
33193331 {
3320- const char *extra_argument = fsplit_arg (storer);
3321-
33223332 argc = get_number_of_args (commands[0].argv);
3323- argv = storer->create_new (argc + 3);
3333+ argv = storer->create_new (argc + 4);
33243334
33253335 memcpy (argv, commands[0].argv, argc * sizeof (const char *));
3326- argv[argc++] = extra_argument;
3336+
3337+ if (!has_hidden_E (argc, commands[0].argv))
3338+ {
3339+ const char *extra_argument = fsplit_arg (storer);
3340+ argv[argc++] = extra_argument;
3341+ }
3342+
33273343 if (have_c)
3328- argv[argc++] = "-fPIE"; /* Necessary when -c is provided for some
3329- reason. */
3344+ argv[argc++] = "-fPIE";
3345+ argv[argc++] = "-fPIC";
3346+
33303347 argv[argc] = NULL;
33313348
33323349 commands[0].argv = argv;
@@ -3854,7 +3871,7 @@ execute (void)
38543871 /* Parse the argbuf into several commands. */
38553872 commands = parse_argbuf (&argbuf, &n_commands);
38563873
3857- if (!have_S)
3874+ if (!have_S && !have_E)
38583875 append_split_outputs (&storer, &additional_ld, &commands, &n_commands);
38593876
38603877 if (!wrapper_string)
@@ -4013,6 +4030,9 @@ static const char *fsplit_arg (extra_arg_storer *storer)
40134030 gcc_assert (current_infile);
40144031
40154032 current_infile->temp_additional_asm = tempname;
4033+ /* Remove file, once we may not even need it and create it later. */
4034+ /* FIXME: This is a little hackish. */
4035+ remove (tempname);
40164036
40174037 final = storer->create_string (n);
40184038
--- a/gcc/lto-partition.c
+++ b/gcc/lto-partition.c
@@ -465,7 +465,7 @@ lto_max_no_alonevap_map (void)
465465 int *compression;
466466
467467 FOR_EACH_SYMBOL (node)
468- node->aux = (void *) n++;
468+ node->aux2 = n++;
469469
470470 union_find disjoint_sets = union_find (n);
471471
@@ -482,9 +482,22 @@ lto_max_no_alonevap_map (void)
482482 FOR_EACH_FUNCTION (cnode)
483483 {
484484 struct ipa_ref *ref = NULL;
485+ cgraph_edge *e;
486+
485487 for (i = 0; cnode->iterate_reference (i, ref); i++)
486- if (is_a <varpool_node *> (ref->referred))
487- disjoint_sets.unite (int_cast (cnode->aux), int_cast (ref->referred->aux));
488+ {
489+ symtab_node *node = ref->referred;
490+ if (is_a <varpool_node *> (node))
491+ disjoint_sets.unite (cnode->aux2, node->aux2);
492+ }
493+
494+ for (e = cnode->callees; e; e = e->next_callee)
495+ {
496+ cgraph_node *node = e->callee;
497+ if (TREE_STATIC (node->decl))
498+ disjoint_sets.unite (cnode->aux2, node->aux2);
499+ }
500+
488501 }
489502
490503 /* Allocate a compression vector, where we will map each disjoint set into
@@ -508,7 +521,7 @@ lto_max_no_alonevap_map (void)
508521 FOR_EACH_SYMBOL (node)
509522 {
510523 int root = disjoint_sets.find (i);
511- node->aux = (void *) root;
524+ node->aux2 = root;
512525 if (compression[root] < 0)
513526 compression[root] = j++;
514527 i++;
@@ -521,8 +534,8 @@ lto_max_no_alonevap_map (void)
521534 variable. Complexity: n. */
522535 FOR_EACH_SYMBOL (node)
523536 {
524- int p = compression[int_cast (node->aux)];
525- node->aux = NULL;
537+ int p = compression[node->aux2];
538+ node->aux2 = -1;
526539
527540 if (node->get_partitioning_class () != SYMBOL_PARTITION
528541 || symbol_partitioned_p (node))
@@ -1360,13 +1373,12 @@ lto_check_usage_from_other_partitions (void)
13601373 for (i = 0; i < ltrans_partitions.length (); i++)
13611374 {
13621375 vec<lto_encoder_entry> &nodes = (ltrans_partitions[i])->encoder->nodes;
1363-
1376+
13641377 for (j = 0; j < nodes.length (); j++)
13651378 {
1366- varpool_node *vnode = dyn_cast<varpool_node *> (nodes[j].node);
1367- if (vnode && !nodes[j].in_partition)
1368- vnode->used_from_other_partition = true;
1379+ symtab_node *node = nodes[j].node;
1380+ if (node && !nodes[j].in_partition)
1381+ node->used_from_other_partition = true;
13691382 }
13701383 }
1371-
13721384 }
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
1+2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br>
2+
3+ * gcc.dg/driver/driver.exp: New test.
4+ * gcc.dg/driver/empty.c: New file.
5+
16 2020-05-27 Giuliano Belinassi <giuliano.belinassi@usp.br>
27
38 * gcc.dg/driver/driver.exp: New test.
--- a/gcc/testsuite/gcc.dg/driver/driver.exp
+++ b/gcc/testsuite/gcc.dg/driver/driver.exp
@@ -55,17 +55,20 @@ check-for-errors "Asembler Generation" \
5555 check-for-errors "Asembler Generation" \
5656 [gcc_target_compile "$srcdir/$subdir/b.c -S" "b.S" none ""]
5757
58+# Empty file is a valid program.
59+check-for-errors "Empty Program" \
60+ [gcc_target_compile "$srcdir/$subdir/empty.c -c" "empty.o" none ""]
61+
5862 # Test object file passthrough
5963 check-for-errors "Object file passthrough" \
6064 [gcc_target_compile "$srcdir/$subdir/foo.c a.o" "a.exe" none ""]
6165
62-
6366 # Test compilation when assembler is provided
6467 check-for-errors "Assembler with Macros" \
6568 [gcc_target_compile "a.S -c" "a.o" none ""]
6669
6770 # Clean temporary generated files.
68-set temp_files {"a.o" "a.S" "b.o" "b.S"}
71+set temp_files {"a.o" "a.S" "b.o" "b.S" "empty.o"}
6972
7073 foreach f $temp_files {
7174 if { [file exists $f] } {