X Tutup
Skip to content

bpo-31374: Create expat_config.h with autoconf#3571

Closed
tiran wants to merge 2 commits intopython:masterfrom
tiran:bpo-31374-expat-warning
Closed

bpo-31374: Create expat_config.h with autoconf#3571
tiran wants to merge 2 commits intopython:masterfrom
tiran:bpo-31374-expat-warning

Conversation

@tiran
Copy link
Copy Markdown
Member

@tiran tiran commented Sep 14, 2017

include expat_config.h first to avoid warning:

"_POSIX_C_SOURCE" redefined

Signed-off-by: Christian Heimes christian@python.org

https://bugs.python.org/issue31374

@vstinner
Copy link
Copy Markdown
Member

Would it be possible to modify expat_config.h instead of modifying code copied from libexpat?

@vstinner
Copy link
Copy Markdown
Member

The AppVeyor failure is unrelated to your change, it's a regression that I introduced when I made threading_cleanup() stricter: https://bugs.python.org/issue31234#msg302163

@tiran
Copy link
Copy Markdown
Member Author

tiran commented Sep 14, 2017

We could fix it in configure.ac by replacing AC_DEFINE for the macro to:

AH_VERBATIM([_POSIX_C_SOURCE],
[/* Define to activate features from IEEE Stds 1003.1-2008 */
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#define _POSIX_C_SOURCE 200809L
])

@vstinner
Copy link
Copy Markdown
Member

Hum, I suggest to not define _POSIX_C_SOURCE if it's already set, rather than replacing the value:

#ifdef _POSIX_C_SOURCE
#  define _POSIX_C_SOURCE 200809L
#endif

Do we really need pyconfig.h to configure expat?

@tiran
Copy link
Copy Markdown
Member Author

tiran commented Sep 14, 2017

We use pyconfig.h to get endianess.

@tiran tiran force-pushed the bpo-31374-expat-warning branch from 64ab171 to 99b2675 Compare September 15, 2017 06:26
@vstinner
Copy link
Copy Markdown
Member

I tried to generate expat_config.h from a expat_config.h.in template which doesn't include pyconfig.h.

Problem: Expat requires the endian, but also the HAVE_MEMMOVE define. I don't know autotools good enough to propose a working change.

I tried the following code in configure.ac:

# Define a BYTEORDER variable for Moules/expat/expat_config.h.in
AC_SUBST(BYTEORDER)
AC_C_BIGENDIAN(
  BYTEORDER=4321,
  BYTEORDER=1234,
  AC_MSG_ERROR(unknown endianess),
  AC_MSG_ERROR(universial endianess not supported)
)

but then noticed that autoheader genereates more complex code in pyconfig.h for the endian:

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
   significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
#  define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
#  undef WORDS_BIGENDIAN
# endif
#endif

Oh wow, I didn't know that getting the endian would be so complex.

I don't know how to pass HAVE_MEMMOVE from configure.ac to my Modules/expat/expat_config.h.in.

Well, as @tiran told me on IRC, my solution is maybe too complex just to fix a single compiler warning :-)

--

But I dislike modifying pyconfig.h because portability is also complex, and I don't know what are the consequences. I proposed a different fix which leaves pyconfig.h unchanged: PR #3601. It also documents what are get from pyconfig.h.

@tiran: What do you think?

@tiran tiran force-pushed the bpo-31374-expat-warning branch from 99b2675 to 65c9f60 Compare September 15, 2017 13:55
Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot the newly added .in file, no?

configure.ac Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may define AC_CONFIG_FILES([Modules/expat/expat_config.h]) here, to group things specific to Expat at the same place. It seems like AC_CONFIG_FILES() can be called multiple times.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep all output files in one place

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This NEWS entry now seems to be outdated.

@bedevere-bot
Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I didn't expect the Spanish Inquisition!. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Fixes warnings in expat module:

  "_POSIX_C_SOURCE" redefined

Signed-off-by: Christian Heimes <christian@python.org>
@tiran tiran force-pushed the bpo-31374-expat-warning branch from 65c9f60 to b95f803 Compare September 15, 2017 14:10
@tiran
Copy link
Copy Markdown
Member Author

tiran commented Sep 15, 2017

I didn't expect the French Inquisition!

And I didn't expect the Spanish Inquisition!

@bedevere-bot
Copy link
Copy Markdown

Nobody expects the Spanish Inquisition!

@Haypo: please review the changes made to this pull request.

@tiran tiran changed the title bpo-31374: Fix build warning in copy of expat bpo-31374: Create expat_config.h with autoconf Sep 15, 2017
@vstinner
Copy link
Copy Markdown
Member

I tested this PR when HAVE_MEMMOVE is false (undefined): expat compilation fails because HAVE_BCOPY is unset, whereas my Fedora 29 supports bcopy() :-/

libexpat uses more "HAVE_xxx" macros:

HAVE_ARC4RANDOM
HAVE_ARC4RANDOM_BUF
HAVE_BCOPY
HAVE_EXPAT_CONFIG_H
HAVE_GETRANDOM
HAVE_LIBBSD
HAVE_SYSCALL_GETRANDOM

expat_config.h seems like the best approach, but I'm not longer sure that it's worth it. This approach requires a lot of work, whereas most platforms use system libexpat, not our vendored libexpat copy.

@vstinner
Copy link
Copy Markdown
Member

This approach seems too complex :-( Since we are trying to fix a minor warning, I wrote a simpler patch which modifies the vendored copy of libexpat: PR #11064.

@vstinner
Copy link
Copy Markdown
Member

I merged a simpler approach: PR #11064.

@vstinner vstinner closed this Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

X Tutup