Patchwork [01/11] nds32: Build Infastructure

login
register
mail settings
Submitter vincentc
Date May 6, 2018, 2:41 p.m.
Message ID <1525617685-32083-2-git-send-email-vincentc@andestech.com>
Download mbox | patch
Permalink /patch/27129/
State New
Headers show

Comments

vincentc - May 6, 2018, 2:41 p.m.
This patch contains all needed Implies, configure and Makefile for nds32
port.
---
 sysdeps/nds32/Implies                        |  3 +++
 sysdeps/nds32/Makefile                       |  9 +++++++
 sysdeps/nds32/configure                      | 35 ++++++++++++++++++++++++++++
 sysdeps/nds32/configure.ac                   | 14 +++++++++++
 sysdeps/nds32/nofpu/Implies                  |  1 +
 sysdeps/nds32/nptl/Makefile                  |  4 ++++
 sysdeps/nds32/preconfigure                   | 20 ++++++++++++++++
 sysdeps/unix/sysv/linux/nds32/Implies        |  3 +++
 sysdeps/unix/sysv/linux/nds32/Makefile       | 17 ++++++++++++++
 sysdeps/unix/sysv/linux/nds32/Versions       | 11 +++++++++
 sysdeps/unix/sysv/linux/nds32/configure      |  4 ++++
 sysdeps/unix/sysv/linux/nds32/configure.ac   |  4 ++++
 sysdeps/unix/sysv/linux/nds32/shlib-versions |  7 ++++++
 13 files changed, 132 insertions(+)
 create mode 100644 sysdeps/nds32/Implies
 create mode 100644 sysdeps/nds32/Makefile
 create mode 100755 sysdeps/nds32/configure
 create mode 100644 sysdeps/nds32/configure.ac
 create mode 100644 sysdeps/nds32/nofpu/Implies
 create mode 100644 sysdeps/nds32/nptl/Makefile
 create mode 100644 sysdeps/nds32/preconfigure
 create mode 100644 sysdeps/unix/sysv/linux/nds32/Implies
 create mode 100644 sysdeps/unix/sysv/linux/nds32/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/nds32/Versions
 create mode 100755 sysdeps/unix/sysv/linux/nds32/configure
 create mode 100644 sysdeps/unix/sysv/linux/nds32/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/nds32/shlib-versions
Joseph Myers - May 8, 2018, 2:49 p.m.
On Sun, 6 May 2018, vincentc wrote:

> diff --git a/sysdeps/nds32/configure.ac b/sysdeps/nds32/configure.ac
> new file mode 100644
> index 0000000..4ca57b8
> --- /dev/null
> +++ b/sysdeps/nds32/configure.ac
> @@ -0,0 +1,14 @@
> +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> +# Local configure fragment for sysdeps/nds32.
> +CFLAGS="$CFLAGS -minline-asm-r15"

If that option is needed globally for building glibc, a comment should be 
there to explain it.

> +AC_CACHE_CHECK(whether gcc support option -mno-scalbn-transform,
> +	       libc_cv_scalbn_transform, [dnl
> +save_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -mno-scalbn-transform"

What does this option do (I don't see it in current GCC)?  Since you've 
said current GCC versions aren't suitable for building glibc, can't you 
just require a compiler supporting the option, unconditionally, so any 
test for it is just to ensure a configure error for a too-old compiler 
rather than allowing compilation to continue without support?
vincentc - May 9, 2018, 8:32 a.m.
On Tue, May 08, 2018 at 10:49:26PM +0800, Joseph Myers wrote:
> On Sun, 6 May 2018, vincentc wrote:
> 
> > diff --git a/sysdeps/nds32/configure.ac b/sysdeps/nds32/configure.ac
> > new file mode 100644
> > index 0000000..4ca57b8
> > --- /dev/null
> > +++ b/sysdeps/nds32/configure.ac
> > @@ -0,0 +1,14 @@
> > +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> > +# Local configure fragment for sysdeps/nds32.
> > +CFLAGS="$CFLAGS -minline-asm-r15"
> 
> If that option is needed globally for building glibc, a comment should be 
> there to explain it.
>
Ok, I will add the following comment in next version patch.

# For nds32 ABI, the $r15 register, assembler reserved register, is also used to
# storing the syscall number for issuing syscall. In order to ensure the data
# safety, $r15 is included in clobber list by default. Using the option
# -minline-asm-r15 can avoid the conflict between asm-specifier for syscall number
# and clobber list when using inline assembly to issue syscall.

 
> > +AC_CACHE_CHECK(whether gcc support option -mno-scalbn-transform,
> > +	       libc_cv_scalbn_transform, [dnl
> > +save_CFLAGS="$CFLAGS"
> > +CFLAGS="$CFLAGS -mno-scalbn-transform"
> 
> What does this option do (I don't see it in current GCC)?  Since you've 
> said current GCC versions aren't suitable for building glibc, can't you 
> just require a compiler supporting the option, unconditionally, so any 
> test for it is just to ensure a configure error for a too-old compiler 
> rather than allowing compilation to continue without support?
> 

The -mno-scalbn-transfomr is used to disable nds32 specific feature in gcc 6.3.0.
(We put nds32 gcc-6.3.0 in the git repo https://github.com/andestech/gcc.git)
However, this feature will be deprecated in the latest gcc. We plan to disable 
this feature by default in gcc-6.3.0 too. Therefore, I will remove this option
from the configure in the next version patch.

Thanks

Best regards
Vincent Chen


> -- 
> Joseph S. Myers
> joseph@codesourcery.com

Patch

diff --git a/sysdeps/nds32/Implies b/sysdeps/nds32/Implies
new file mode 100644
index 0000000..387a0ca
--- /dev/null
+++ b/sysdeps/nds32/Implies
@@ -0,0 +1,3 @@ 
+wordsize-32
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/sysdeps/nds32/Makefile b/sysdeps/nds32/Makefile
new file mode 100644
index 0000000..5651161
--- /dev/null
+++ b/sysdeps/nds32/Makefile
@@ -0,0 +1,9 @@ 
+ifeq ($(subdir),elf)
+sysdep-dl-routines += tlsdesc dl-tlsdesc
+sysdep_routines += tlsdesc dl-tlsdesc
+sysdep-rtld-routines += tlsdesc dl-tlsdesc
+endif
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tlsdesc.sym
+endif
diff --git a/sysdeps/nds32/configure b/sysdeps/nds32/configure
new file mode 100755
index 0000000..42eb9bb
--- /dev/null
+++ b/sysdeps/nds32/configure
@@ -0,0 +1,35 @@ 
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/nds32.
+CFLAGS="$CFLAGS -minline-asm-r15"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc support option -mno-scalbn-transform" >&5
+$as_echo_n "checking whether gcc support option -mno-scalbn-transform... " >&6; }
+if ${libc_cv_scalbn_transform+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -mno-scalbn-transform"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_cv_scalbn_transform=yes
+else
+  libc_cv_scalbn_transform=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="$save_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_scalbn_transform" >&5
+$as_echo "$libc_cv_scalbn_transform" >&6; }
+if test "$libc_cv_scalbn_transform" = yes; then
+CFLAGS="$CFLAGS -mno-scalbn-transform"
+fi
diff --git a/sysdeps/nds32/configure.ac b/sysdeps/nds32/configure.ac
new file mode 100644
index 0000000..4ca57b8
--- /dev/null
+++ b/sysdeps/nds32/configure.ac
@@ -0,0 +1,14 @@ 
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/nds32.
+CFLAGS="$CFLAGS -minline-asm-r15"
+AC_CACHE_CHECK(whether gcc support option -mno-scalbn-transform,
+	       libc_cv_scalbn_transform, [dnl
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -mno-scalbn-transform"
+AC_TRY_COMPILE(,,
+	       libc_cv_scalbn_transform=yes,
+	       libc_cv_scalbn_transform=no)
+CFLAGS="$save_CFLAGS"])
+if test "$libc_cv_scalbn_transform" = yes; then
+CFLAGS="$CFLAGS -mno-scalbn-transform"
+fi
diff --git a/sysdeps/nds32/nofpu/Implies b/sysdeps/nds32/nofpu/Implies
new file mode 100644
index 0000000..abcbadb
--- /dev/null
+++ b/sysdeps/nds32/nofpu/Implies
@@ -0,0 +1 @@ 
+ieee754/soft-fp
diff --git a/sysdeps/nds32/nptl/Makefile b/sysdeps/nds32/nptl/Makefile
new file mode 100644
index 0000000..6f553d6
--- /dev/null
+++ b/sysdeps/nds32/nptl/Makefile
@@ -0,0 +1,4 @@ 
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/sysdeps/nds32/preconfigure b/sysdeps/nds32/preconfigure
new file mode 100644
index 0000000..9154423
--- /dev/null
+++ b/sysdeps/nds32/preconfigure
@@ -0,0 +1,20 @@ 
+case "$machine" in
+nds32*)
+    float_abi_type=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __NDS32_EXT_FPU_\([S|D]P*\) 1/\1/p' | wc -l`
+
+    case "$float_abi_type" in
+    0)
+       with_fp_cond=0
+       ;;
+    *)
+       echo "glibc does not yet support systems with FP instructions" >&2
+       exit 1
+       ;;
+    esac
+
+    base_machine=nds32
+    machine=nds32
+
+    $as_echo "#define NDS32_ABI_TYPE $float_abi_type" >>confdefs.h
+    ;;
+esac
diff --git a/sysdeps/unix/sysv/linux/nds32/Implies b/sysdeps/unix/sysv/linux/nds32/Implies
new file mode 100644
index 0000000..91b4e1e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nds32/Implies
@@ -0,0 +1,3 @@ 
+nds32/nptl
+unix/sysv/linux/generic/wordsize-32
+unix/sysv/linux/generic
diff --git a/sysdeps/unix/sysv/linux/nds32/Makefile b/sysdeps/unix/sysv/linux/nds32/Makefile
new file mode 100644
index 0000000..2709916
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nds32/Makefile
@@ -0,0 +1,17 @@ 
+ifeq ($(subdir),misc)
+sysdep_headers += sys/cachectl.h
+sysdep_routines += cacheflush prctl mremap
+endif
+
+
+ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext_i.sym
+endif
+
+ifeq ($(subdir),elf)
+sysdep_routines += dl-vdso
+ifeq ($(build-shared),yes)
+# This is needed for DSO loading from static binaries.
+sysdep-dl-routines += dl-static
+endif
+endif
diff --git a/sysdeps/unix/sysv/linux/nds32/Versions b/sysdeps/unix/sysv/linux/nds32/Versions
new file mode 100644
index 0000000..abe47ce
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nds32/Versions
@@ -0,0 +1,11 @@ 
+ld {
+  GLIBC_PRIVATE {
+  # used for loading by static libraries
+    _dl_var_init;
+  }
+}
+libc {
+  GLIBC_2.28 {
+    cacheflush;
+  }
+}
diff --git a/sysdeps/unix/sysv/linux/nds32/configure b/sysdeps/unix/sysv/linux/nds32/configure
new file mode 100755
index 0000000..e815611
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nds32/configure
@@ -0,0 +1,4 @@ 
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/nds32.
+
+arch_minimum_kernel=4.16.0
diff --git a/sysdeps/unix/sysv/linux/nds32/configure.ac b/sysdeps/unix/sysv/linux/nds32/configure.ac
new file mode 100644
index 0000000..a5a0593
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nds32/configure.ac
@@ -0,0 +1,4 @@ 
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/nds32.
+
+arch_minimum_kernel=4.16.0
diff --git a/sysdeps/unix/sysv/linux/nds32/shlib-versions b/sysdeps/unix/sysv/linux/nds32/shlib-versions
new file mode 100644
index 0000000..2131996
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nds32/shlib-versions
@@ -0,0 +1,7 @@ 
+DEFAULT			GLIBC_2.28
+
+%if NDS32_ABI_TYPE == 0
+ld=ld-linux-nds32.so.1
+%else
+%error cannot determine ABI
+%endif