]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Add an error message in large code model for ilp32 [PR94577]
authorXieZhiheng <xiezhiheng@huawei.com>
Tue, 21 Apr 2020 14:09:23 +0000 (15:09 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 21 Apr 2020 14:09:23 +0000 (15:09 +0100)
The option -mabi=ilp32 should not be used in large code model. An error
message is added for the option conflict.

2020-04-21  Duan bo  <duanbo3@huawei.com>

gcc/
PR target/94577
* config/aarch64/aarch64.c: Add an error message for option conflict.
* doc/invoke.texi (-mcmodel=large): Mention that -mcmodel=large is
incompatible with -fpic, -fPIC and -mabi=ilp32.

gcc/testsuite/
PR target/94577
* gcc.target/aarch64/pr94577.c: New test.

gcc/ChangeLog
gcc/config/aarch64/aarch64.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/pr94577.c [new file with mode: 0644]

index c3572ca03bd0e1c0c91164bcc281dbc6a109ed6e..dc831f6725b530a15c4c29728469c1dca9932e88 100644 (file)
@@ -1,3 +1,10 @@
+2020-04-21  Duan bo  <duanbo3@huawei.com>
+
+       PR target/94577
+       * config/aarch64/aarch64.c: Add an error message for option conflict.
+       * doc/invoke.texi (-mcmodel=large): Mention that -mcmodel=large is
+       incompatible with -fpic, -fPIC and -mabi=ilp32.
+
 2020-04-21  Frederik Harwath  <frederik@codesourcery.com>
 
        PR other/94629
index ee6a2de77a59765f94c900eb769aad5ea2a4cd04..f728ac530a4ac968de16ea59d2b724ed63b23d6f 100644 (file)
@@ -14777,32 +14777,37 @@ aarch64_init_expanders (void)
 static void
 initialize_aarch64_code_model (struct gcc_options *opts)
 {
-   if (opts->x_flag_pic)
-     {
-       switch (opts->x_aarch64_cmodel_var)
-        {
-        case AARCH64_CMODEL_TINY:
-          aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
-          break;
-        case AARCH64_CMODEL_SMALL:
+  aarch64_cmodel = opts->x_aarch64_cmodel_var;
+  switch (opts->x_aarch64_cmodel_var)
+    {
+    case AARCH64_CMODEL_TINY:
+      if (opts->x_flag_pic)
+       aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
+      break;
+    case AARCH64_CMODEL_SMALL:
+      if (opts->x_flag_pic)
+       {
 #ifdef HAVE_AS_SMALL_PIC_RELOCS
-          aarch64_cmodel = (flag_pic == 2
-                            ? AARCH64_CMODEL_SMALL_PIC
-                            : AARCH64_CMODEL_SMALL_SPIC);
+         aarch64_cmodel = (flag_pic == 2
+                           ? AARCH64_CMODEL_SMALL_PIC
+                           : AARCH64_CMODEL_SMALL_SPIC);
 #else
-          aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
+         aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
 #endif
-          break;
-        case AARCH64_CMODEL_LARGE:
-          sorry ("code model %qs with %<-f%s%>", "large",
-                 opts->x_flag_pic > 1 ? "PIC" : "pic");
-          break;
-        default:
-          gcc_unreachable ();
-        }
-     }
-   else
-     aarch64_cmodel = opts->x_aarch64_cmodel_var;
+       }
+      break;
+    case AARCH64_CMODEL_LARGE:
+      if (opts->x_flag_pic)
+       sorry ("code model %qs with %<-f%s%>", "large",
+              opts->x_flag_pic > 1 ? "PIC" : "pic");
+      if (opts->x_aarch64_abi == AARCH64_ABI_ILP32)
+       sorry ("code model %qs not supported in ilp32 mode", "large");
+      break;
+    case AARCH64_CMODEL_TINY_PIC:
+    case AARCH64_CMODEL_SMALL_PIC:
+    case AARCH64_CMODEL_SMALL_SPIC:
+      gcc_unreachable ();
+    }
 }
 
 /* Implement TARGET_OPTION_SAVE.  */
index 8b5cd8246a925c44890f7c36b0b0bbba119ea3f1..d47488240cfacfd3f30649cfd75102c137f6a8ea 100644 (file)
@@ -16759,7 +16759,9 @@ dynamically linked.  This is the default code model.
 @item -mcmodel=large
 @opindex mcmodel=large
 Generate code for the large code model.  This makes no assumptions about
-addresses and sizes of sections.  Programs can be statically linked only.
+addresses and sizes of sections.  Programs can be statically linked only.  The
+@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
+@option{-fpic} and @option{-fPIC}.
 
 @item -mstrict-align
 @itemx -mno-strict-align
index 372a89f95781c7cbf2df497481bb37b35c5fa7f7..0de5a470ec6c5bc4a401ebf12e5c15b39601f68c 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-21  Duan bo  <duanbo3@huawei.com>
+
+       PR target/94577
+       * gcc.target/aarch64/pr94577.c: New test.
+
 2020-04-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/94686
diff --git a/gcc/testsuite/gcc.target/aarch64/pr94577.c b/gcc/testsuite/gcc.target/aarch64/pr94577.c
new file mode 100644 (file)
index 0000000..6f2d361
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mcmodel=large -mabi=ilp32" } */
+
+void
+foo ()
+{
+  // Do nothing
+}
+
+/* { dg-message "sorry, unimplemented: code model 'large' not supported in ilp32 mode"  "" { target *-*-* } 0 } */