public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Nicholas Guriev <nicholas@guriev.su>
To: libc-help@sourceware.org
Subject: [RFC PATCH v1 1/1] draft: Make non-optimized build possible
Date: Mon, 2 May 2022 15:08:20 +0300	[thread overview]
Message-ID: <e111ad896e0d10e67ae043ebef7ea8ec20725ac5.1651500717.git.nicholas@guriev.su> (raw)
In-Reply-To: <cover.1651500717.git.nicholas@guriev.su>

Fix compilation errors found with the -O0 flag. Autotests do not work yet.
Checked in GNU/Linux Ubuntu 21.10 with GCC 11.2.0.
---
 include/alloc_buffer.h             | 76 ++++++++++++++++--------------
 include/libc-symbols.h             |  6 +--
 include/rtld-malloc.h              |  8 ++--
 locale/programs/locfile.h          |  2 +-
 nscd/nscd-client.h                 |  2 +-
 resolv/gai_misc.c                  |  2 +-
 rt/aio_misc.c                      |  2 +-
 sysdeps/nptl/gai_misc.h            |  4 +-
 sysdeps/unix/sysv/linux/aio_misc.h |  4 +-
 9 files changed, 56 insertions(+), 50 deletions(-)

diff --git a/include/alloc_buffer.h b/include/alloc_buffer.h
index be33e8b68c..1d431d3ad4 100644
--- a/include/alloc_buffer.h
+++ b/include/alloc_buffer.h
@@ -202,44 +202,50 @@ alloc_buffer_alloc_bytes (struct alloc_buffer *buf, size_t length)
 
 /* Internal function.  Statically assert that the type size is
    constant and valid.  */
-static __always_inline size_t
-__alloc_buffer_assert_size (size_t size)
-{
-  if (!__builtin_constant_p (size))
-    {
-      __errordecl (error, "type size is not constant");
-      error ();
-    }
-  else if (size == 0)
-    {
-      __errordecl (error, "type size is zero");
-      error ();
-    }
-  return size;
-}
+//static __always_inline size_t
+//__alloc_buffer_assert_size (size_t size)
+//{
+//  if (!__builtin_constant_p (size))
+//    {
+//      __errordecl (error, "type size is not constant");
+//      error ();
+//    }
+//  else if (size == 0)
+//    {
+//      __errordecl (error, "type size is zero");
+//      error ();
+//    }
+//  return size;
+//}
+
+#define __alloc_buffer_assert_size(val) \
+  ({ _Static_assert (val > 0, "positive size"); val; })
 
 /* Internal function.  Statically assert that the type alignment is
    constant and valid.  */
-static __always_inline size_t
-__alloc_buffer_assert_align (size_t align)
-{
-  if (!__builtin_constant_p (align))
-    {
-      __errordecl (error, "type alignment is not constant");
-      error ();
-    }
-  else if (align == 0)
-    {
-      __errordecl (error, "type alignment is zero");
-      error ();
-    }
-  else if (!powerof2 (align))
-    {
-      __errordecl (error, "type alignment is not a power of two");
-      error ();
-    }
-  return align;
-}
+//static __always_inline size_t
+//__alloc_buffer_assert_align (size_t align)
+//{
+//  if (!__builtin_constant_p (align))
+//    {
+//      __errordecl (error, "type alignment is not constant");
+//      error ();
+//    }
+//  else if (align == 0)
+//    {
+//      __errordecl (error, "type alignment is zero");
+//      error ();
+//    }
+//  else if (!powerof2 (align))
+//    {
+//      __errordecl (error, "type alignment is not a power of two");
+//      error ();
+//    }
+//  return align;
+//}
+
+#define __alloc_buffer_assert_align(val) \
+  ({ _Static_assert (val > 0 && powerof2 (val), "type alignment"); val; })
 
 /* Internal function.  Obtain a pointer to an object.  */
 static inline __attribute__ ((nonnull (1))) void *
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 662bd118b1..e5651802a6 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -71,9 +71,9 @@
 #define _LIBC	1
 
 /* Some files must be compiled with optimization on.  */
-#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__
-# error "glibc cannot be compiled without optimization"
-#endif
+//#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__
+//# error "glibc cannot be compiled without optimization"
+//#endif
 
 /* -ffast-math cannot be applied to the C library, as it alters the ABI.
    Some test components that use -ffast-math are currently not part of
diff --git a/include/rtld-malloc.h b/include/rtld-malloc.h
index ed70c87f40..0d7d7e7a07 100644
--- a/include/rtld-malloc.h
+++ b/include/rtld-malloc.h
@@ -38,25 +38,25 @@ extern __typeof (realloc) *__rtld_realloc attribute_hidden;
    functions.  Instead the function pointers must be used
    directly.  */
 
-__extern_inline void *
+__extern_always_inline void *
 calloc (size_t a, size_t b)
 {
   return __rtld_calloc (a, b);
 }
 
-__extern_inline void
+__extern_always_inline void
 free (void *ptr)
 {
    __rtld_free (ptr);
 }
 
-__extern_inline void *
+__extern_always_inline void *
 malloc (size_t size)
 {
   return __rtld_malloc (size);
 }
 
-__extern_inline void *
+__extern_always_inline void *
 realloc (void *ptr, size_t size)
 {
   return __rtld_realloc (ptr, size);
diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h
index 57b2211e2f..894df6bbde 100644
--- a/locale/programs/locfile.h
+++ b/locale/programs/locfile.h
@@ -80,7 +80,7 @@ set_big_endian (bool big_endian)
 
 /* Munge VALUE so that, when stored, it has the correct byte order
    for the output files.  */
-static uint32_t
+static inline uint32_t
 __attribute__ ((unused))
 maybe_swap_uint32 (uint32_t value)
 {
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index fee2a15dcc..eaa8d7abc5 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -407,7 +407,7 @@ extern void __nscd_unmap (struct mapped_database *mapped)
   attribute_hidden;
 
 /* Drop reference of mapping.  */
-static int
+static inline int
 __attribute__ ((unused))
 __nscd_drop_map_ref (struct mapped_database *map, int *gc_cycle)
 {
diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index 8ce3c778eb..2102e1797d 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -37,7 +37,7 @@
 #ifndef gai_create_helper_thread
 # define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline int
+extern __always_inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/rt/aio_misc.c b/rt/aio_misc.c
index b4304d0a6f..dc18618473 100644
--- a/rt/aio_misc.c
+++ b/rt/aio_misc.c
@@ -45,7 +45,7 @@
 #ifndef aio_create_helper_thread
 # define aio_create_helper_thread __aio_create_helper_thread
 
-extern inline int
+extern __always__inline int
 __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)
 {
   pthread_attr_t attr;
diff --git a/sysdeps/nptl/gai_misc.h b/sysdeps/nptl/gai_misc.h
index c09350c2ed..49beefed1c 100644
--- a/sysdeps/nptl/gai_misc.h
+++ b/sysdeps/nptl/gai_misc.h
@@ -76,7 +76,7 @@
 #define gai_start_notify_thread __gai_start_notify_thread
 #define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline void
+extern __always_inline void
 __gai_start_notify_thread (void)
 {
   sigset_t ss;
@@ -86,7 +86,7 @@ __gai_start_notify_thread (void)
   assert_perror (sigerr);
 }
 
-extern inline int
+extern __always_inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/sysdeps/unix/sysv/linux/aio_misc.h b/sysdeps/unix/sysv/linux/aio_misc.h
index 100334ad45..aa753fbd23 100644
--- a/sysdeps/unix/sysv/linux/aio_misc.h
+++ b/sysdeps/unix/sysv/linux/aio_misc.h
@@ -25,7 +25,7 @@
 # define aio_start_notify_thread __aio_start_notify_thread
 # define aio_create_helper_thread __aio_create_helper_thread
 
-extern inline void
+extern __always_inline void
 __aio_start_notify_thread (void)
 {
   sigset_t ss;
@@ -34,7 +34,7 @@ __aio_start_notify_thread (void)
 			 __NSIG_BYTES);
 }
 
-extern inline int
+extern __always_inline int
 __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
-- 
2.32.0


      reply	other threads:[~2022-05-02 14:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 14:11 [RFC PATCH v1 0/1] Debug build? Nicholas Guriev
2022-05-02 12:08 ` Nicholas Guriev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e111ad896e0d10e67ae043ebef7ea8ec20725ac5.1651500717.git.nicholas@guriev.su \
    --to=nicholas@guriev.su \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).