Re: [Tinycc-devel] A Patch for -dumpmachine Option

2022-03-24 Thread Christian Jullien
I don't know if your patch will reach mob or not but, if it does, IMHO, to be 
useful, the output string should match what gcc/clang currently reports.

For example:

RPi 32bit reports:
$ gcc -dumpmachine
arm-linux-gnueabihf

RPi 64bit reports:
$ gcc -dumpmachine
aarch64-linux-gnu

Windows reports:
gcc -dumpmachine
x86_64-pc-cygwin

or

clang -dumpmachine
x86_64-pc-windows-msvc

macOS:
jullien@mobley:~ $ clang -dumpmachine
arm64-apple-darwin21.4.0
jullien@mobley:~ $ clang -arch x86_64 -dumpmachine
x86_64-apple-darwin21.4.0

etc...

-Original Message-
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On 
Behalf Of Ziyao
Sent: Thursday, March 24, 2022 11:36
To: Tinycc-devel@nongnu.org
Subject: [Tinycc-devel] A Patch for -dumpmachine Option

Hi list,

I have made a small patch which adds option "-dumpmachine" support to
TinyCC.This option is widely supported by both gcc and clang.Some configure
scripts detect the platform information by passing this option to the
C compiler,such as musl libc.

And by the way,what is the proper way to contribute? Just send patches to
this maillist or what?Should I send a normal patch or formatted patch?
Thanks for answering.

(To avoid messing the plaintext mail readers up,I add my patch to the bottom
of this mail.)

Cheers,
Ziyao

--

diff --git a/libtcc.c b/libtcc.c
index b6dbb01..6e5cf17 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1456,6 +1456,7 @@ enum {
 TCC_OPTION_g,
 TCC_OPTION_c,
 TCC_OPTION_dumpversion,
+TCC_OPTION_DUMPMACHINE,
 TCC_OPTION_d,
 TCC_OPTION_static,
 TCC_OPTION_std,
@@ -1488,7 +1489,7 @@ enum {
 TCC_OPTION_MMD,
 TCC_OPTION_x,
 TCC_OPTION_ar,
-TCC_OPTION_impdef,
+TCC_OPTION_impdef
 };
 
 #define TCC_OPTION_HAS_ARG 0x0001
@@ -1518,6 +1519,7 @@ static const TCCOption tcc_options[] = {
 { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
 { "c", TCC_OPTION_c, 0 },
 { "dumpversion", TCC_OPTION_dumpversion, 0},
+{ "dumpmachine", TCC_OPTION_DUMPMACHINE , 0 },
 { "d", TCC_OPTION_d, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
 { "static", TCC_OPTION_static, 0 },
 { "std", TCC_OPTION_std, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1952,6 +1954,8 @@ reparse:
 printf ("%s\n", TCC_VERSION);
 exit(0);
 break;
+case TCC_OPTION_DUMPMACHINE:
+return OPT_DUMPMACHINE;
 case TCC_OPTION_x:
 x = 0;
 if (*optarg == 'c')
diff --git a/tcc.c b/tcc.c
index 42a251b..ed9c143 100644
--- a/tcc.c
+++ b/tcc.c
@@ -95,6 +95,7 @@ static const char help2[] =
 "  -isystem dir  add 'dir' to system include path\n"
 "  -static   link to static libraries (not 
recommended)\n"
 "  -dumpversion  print version\n"
+"  -dumpmachine  print platform information\n"
 "  -print-search-dirsprint search paths\n"
 "  -dt   with -run/-E: auto-define 'test_...' 
macros\n"
 "Ignored options:\n"
@@ -289,6 +290,47 @@ redo:
 return 0;
 ++opt;
 }
+
+if (opt == OPT_DUMPMACHINE) {
+fputs(
+#ifdef TCC_TARGET_I386
+"i386"
+#elif defined TCC_TARGET_X86_64
+"x86_64"
+#elif defined TCC_TARGET_C67
+"c67"
+#elif defined TCC_TARGET_ARM
+"arm"
+# ifdef TCC_ARM_EABI
+" eabi"
+#  ifdef TCC_ARM_HARDFLOAT
+"hf"
+#  endif
+# endif
+#elif defined TCC_TARGET_ARM64
+"aarch64"
+#elif defined TCC_TARGET_RISCV64
+"riscv64"
+#endif
+   "-"
+#ifdef TCC_TARGET_PE
+"windows"
+#elif defined(TCC_TARGET_MACHO)
+"darwin"
+#elif TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel
+"freebsd"
+#elif TARGETOS_OpenBSD
+"openbsd"
+#elif TARGETOS_NetBSD
+"netbsd"
+#else
+"linux"
+#endif
+"-tcc\n",stdout);
+return 0;
+
+}
+
 if (opt == OPT_HELP2) {
 fputs(help2, stdout);
 return 0;
diff --git a/tcc.h b/tcc.h
index 9724848..3812241 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1279,6 +1279,7 @@ ST_FUNC char *tcc_load_text(int fd);
 #define OPT_PRINT_DIRS 4
 #define OPT_AR 5
 #define OPT_IMPDEF 6
+#define OPT_DUMPMACHINE 7
 #define OPT_M32 32
 #define OPT_M64 64


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] A Patch for -dumpmachine Option

2022-03-24 Thread Domingo Alvarez Duarte
Looking at the patch I think that somehow it can be a good idea to 
create a new header/source to hold all (or as much as possible) of the 
platforms machinery in one place instead of spread through everywhere, 
like the functionality of "-dumpmachine" would be on that header/source.


On 24/3/22 11:35, Ziyao wrote:

Hi list,

I have made a small patch which adds option "-dumpmachine" support to
TinyCC.This option is widely supported by both gcc and clang.Some configure
scripts detect the platform information by passing this option to the
C compiler,such as musl libc.

And by the way,what is the proper way to contribute? Just send patches to
this maillist or what?Should I send a normal patch or formatted patch?
Thanks for answering.

(To avoid messing the plaintext mail readers up,I add my patch to the bottom
of this mail.)

Cheers,
Ziyao

--

diff --git a/libtcc.c b/libtcc.c
index b6dbb01..6e5cf17 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1456,6 +1456,7 @@ enum {
  TCC_OPTION_g,
  TCC_OPTION_c,
  TCC_OPTION_dumpversion,
+TCC_OPTION_DUMPMACHINE,
  TCC_OPTION_d,
  TCC_OPTION_static,
  TCC_OPTION_std,
@@ -1488,7 +1489,7 @@ enum {
  TCC_OPTION_MMD,
  TCC_OPTION_x,
  TCC_OPTION_ar,
-TCC_OPTION_impdef,
+TCC_OPTION_impdef
  };
  
  #define TCC_OPTION_HAS_ARG 0x0001

@@ -1518,6 +1519,7 @@ static const TCCOption tcc_options[] = {
  { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
  { "c", TCC_OPTION_c, 0 },
  { "dumpversion", TCC_OPTION_dumpversion, 0},
+{ "dumpmachine", TCC_OPTION_DUMPMACHINE , 0 },
  { "d", TCC_OPTION_d, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
  { "static", TCC_OPTION_static, 0 },
  { "std", TCC_OPTION_std, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1952,6 +1954,8 @@ reparse:
  printf ("%s\n", TCC_VERSION);
  exit(0);
  break;
+case TCC_OPTION_DUMPMACHINE:
+return OPT_DUMPMACHINE;
  case TCC_OPTION_x:
  x = 0;
  if (*optarg == 'c')
diff --git a/tcc.c b/tcc.c
index 42a251b..ed9c143 100644
--- a/tcc.c
+++ b/tcc.c
@@ -95,6 +95,7 @@ static const char help2[] =
  "  -isystem dir  add 'dir' to system include path\n"
  "  -static   link to static libraries (not 
recommended)\n"
  "  -dumpversion  print version\n"
+"  -dumpmachine  print platform information\n"
  "  -print-search-dirsprint search paths\n"
  "  -dt   with -run/-E: auto-define 'test_...' 
macros\n"
  "Ignored options:\n"
@@ -289,6 +290,47 @@ redo:
  return 0;
  ++opt;
  }
+
+if (opt == OPT_DUMPMACHINE) {
+fputs(
+#ifdef TCC_TARGET_I386
+"i386"
+#elif defined TCC_TARGET_X86_64
+"x86_64"
+#elif defined TCC_TARGET_C67
+"c67"
+#elif defined TCC_TARGET_ARM
+"arm"
+# ifdef TCC_ARM_EABI
+" eabi"
+#  ifdef TCC_ARM_HARDFLOAT
+"hf"
+#  endif
+# endif
+#elif defined TCC_TARGET_ARM64
+"aarch64"
+#elif defined TCC_TARGET_RISCV64
+"riscv64"
+#endif
+   "-"
+#ifdef TCC_TARGET_PE
+"windows"
+#elif defined(TCC_TARGET_MACHO)
+"darwin"
+#elif TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel
+"freebsd"
+#elif TARGETOS_OpenBSD
+"openbsd"
+#elif TARGETOS_NetBSD
+"netbsd"
+#else
+"linux"
+#endif
+"-tcc\n",stdout);
+return 0;
+
+}
+
  if (opt == OPT_HELP2) {
  fputs(help2, stdout);
  return 0;
diff --git a/tcc.h b/tcc.h
index 9724848..3812241 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1279,6 +1279,7 @@ ST_FUNC char *tcc_load_text(int fd);
  #define OPT_PRINT_DIRS 4
  #define OPT_AR 5
  #define OPT_IMPDEF 6
+#define OPT_DUMPMACHINE 7
  #define OPT_M32 32
  #define OPT_M64 64


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] A Patch for -dumpmachine Option

2022-03-24 Thread Ziyao
Hi list,

I have made a small patch which adds option "-dumpmachine" support to
TinyCC.This option is widely supported by both gcc and clang.Some configure
scripts detect the platform information by passing this option to the
C compiler,such as musl libc.

And by the way,what is the proper way to contribute? Just send patches to
this maillist or what?Should I send a normal patch or formatted patch?
Thanks for answering.

(To avoid messing the plaintext mail readers up,I add my patch to the bottom
of this mail.)

Cheers,
Ziyao

--

diff --git a/libtcc.c b/libtcc.c
index b6dbb01..6e5cf17 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1456,6 +1456,7 @@ enum {
 TCC_OPTION_g,
 TCC_OPTION_c,
 TCC_OPTION_dumpversion,
+TCC_OPTION_DUMPMACHINE,
 TCC_OPTION_d,
 TCC_OPTION_static,
 TCC_OPTION_std,
@@ -1488,7 +1489,7 @@ enum {
 TCC_OPTION_MMD,
 TCC_OPTION_x,
 TCC_OPTION_ar,
-TCC_OPTION_impdef,
+TCC_OPTION_impdef
 };
 
 #define TCC_OPTION_HAS_ARG 0x0001
@@ -1518,6 +1519,7 @@ static const TCCOption tcc_options[] = {
 { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
 { "c", TCC_OPTION_c, 0 },
 { "dumpversion", TCC_OPTION_dumpversion, 0},
+{ "dumpmachine", TCC_OPTION_DUMPMACHINE , 0 },
 { "d", TCC_OPTION_d, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
 { "static", TCC_OPTION_static, 0 },
 { "std", TCC_OPTION_std, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1952,6 +1954,8 @@ reparse:
 printf ("%s\n", TCC_VERSION);
 exit(0);
 break;
+case TCC_OPTION_DUMPMACHINE:
+return OPT_DUMPMACHINE;
 case TCC_OPTION_x:
 x = 0;
 if (*optarg == 'c')
diff --git a/tcc.c b/tcc.c
index 42a251b..ed9c143 100644
--- a/tcc.c
+++ b/tcc.c
@@ -95,6 +95,7 @@ static const char help2[] =
 "  -isystem dir  add 'dir' to system include path\n"
 "  -static   link to static libraries (not 
recommended)\n"
 "  -dumpversion  print version\n"
+"  -dumpmachine  print platform information\n"
 "  -print-search-dirsprint search paths\n"
 "  -dt   with -run/-E: auto-define 'test_...' 
macros\n"
 "Ignored options:\n"
@@ -289,6 +290,47 @@ redo:
 return 0;
 ++opt;
 }
+
+if (opt == OPT_DUMPMACHINE) {
+fputs(
+#ifdef TCC_TARGET_I386
+"i386"
+#elif defined TCC_TARGET_X86_64
+"x86_64"
+#elif defined TCC_TARGET_C67
+"c67"
+#elif defined TCC_TARGET_ARM
+"arm"
+# ifdef TCC_ARM_EABI
+" eabi"
+#  ifdef TCC_ARM_HARDFLOAT
+"hf"
+#  endif
+# endif
+#elif defined TCC_TARGET_ARM64
+"aarch64"
+#elif defined TCC_TARGET_RISCV64
+"riscv64"
+#endif
+   "-"
+#ifdef TCC_TARGET_PE
+"windows"
+#elif defined(TCC_TARGET_MACHO)
+"darwin"
+#elif TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel
+"freebsd"
+#elif TARGETOS_OpenBSD
+"openbsd"
+#elif TARGETOS_NetBSD
+"netbsd"
+#else
+"linux"
+#endif
+"-tcc\n",stdout);
+return 0;
+
+}
+
 if (opt == OPT_HELP2) {
 fputs(help2, stdout);
 return 0;
diff --git a/tcc.h b/tcc.h
index 9724848..3812241 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1279,6 +1279,7 @@ ST_FUNC char *tcc_load_text(int fd);
 #define OPT_PRINT_DIRS 4
 #define OPT_AR 5
 #define OPT_IMPDEF 6
+#define OPT_DUMPMACHINE 7
 #define OPT_M32 32
 #define OPT_M64 64


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel