Merge commit 'accb06120c13a4ead442464d96f2fa318fa07a4e'
authorJames Almer <jamrial@gmail.com>
Sat, 11 Nov 2017 14:40:06 +0000 (11:40 -0300)
committerJames Almer <jamrial@gmail.com>
Sat, 11 Nov 2017 16:15:42 +0000 (13:15 -0300)
* commit 'accb06120c13a4ead442464d96f2fa318fa07a4e':
  configure: Use dllexport/dllimport for data symbols across DLLs with mingw

Merged-by: James Almer <jamrial@gmail.com>
1  2 
configure
libavcodec/internal.h
libavutil/internal.h

diff --cc configure
+++ b/configure
@@@ -5038,45 -4026,28 +5038,43 @@@ case $target_os i
          if enabled x86_64; then
              LIBTARGET="i386:x86-64"
          fi
 -        check_ldflags -Wl,--nxcompat
 -        check_ldflags -Wl,--dynamicbase
+         if enabled shared; then
+             # Cannot build both shared and static libs when using dllexport.
+             disable static
+         fi
 +        enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
 +        enabled x86_32 && check_ldflags -Wl,--large-address-aware
          shlibdir_default="$bindir_default"
          SLIBPREF=""
          SLIBSUF=".dll"
 -        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
 -        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
 +        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
 +        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
-         dlltool="${cross_prefix}dlltool"
-         if check_cmd lib.exe -list; then
-             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
-             if enabled x86_64; then
-                 LIBTARGET=x64
-             fi
-         elif check_cmd $dlltool --version; then
-             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
-         fi
+         SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
          SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
          SLIB_INSTALL_LINKS=
          SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
          SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
-         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--disable-auto-image-base'
+         SLIB_CREATE_DEF_CMD='ARCH="$(ARCH)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
 -        SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-auto-image-base $$(@:$(SLIBSUF)=.def)'
++        SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--disable-auto-image-base $$(@:$(SLIBSUF)=.def)'
          enabled x86_64 && objformat="win64" || objformat="win32"
+         dlltool="${cross_prefix}dlltool"
          ranlib=:
          enable dos_paths
 +        check_ldflags -Wl,--nxcompat,--dynamicbase
 +        # Lets work around some stupidity in binutils.
 +        # ld will strip relocations from executables even though we need them
 +        # for dynamicbase (ASLR).  Using -pie does retain the reloc section
 +        # however ld then forgets what the entry point should be (oops) so we
 +        # have to manually (re)set it.
 +        if enabled x86_32; then
 +            disabled debug && add_ldexeflags -Wl,--pic-executable,-e,_mainCRTStartup
 +        elif enabled x86_64; then
 +            disabled debug && add_ldexeflags -Wl,--pic-executable,-e,mainCRTStartup
 +            check_ldflags -Wl,--high-entropy-va # binutils 2.25
 +            # Set image base >4GB for extra entropy with HEASLR
 +            add_ldexeflags -Wl,--image-base,0x140000000
 +            append SHFLAGS -Wl,--image-base,0x180000000
 +        fi
          ;;
      win32|win64)
          disable symver
@@@ -6931,11 -5437,10 +6929,13 @@@ DEPX86ASMFLAGS=\$(X86ASMFLAGS
  AR=$ar
  ARFLAGS=$arflags
  AR_O=$ar_o
+ AR_CMD=$ar
+ NM_CMD=$nm
  RANLIB=$ranlib
  STRIP=$strip
 +STRIPTYPE=$striptype
 +NVCC=$nvcc
 +CP=cp -p
  LN_S=$ln_s
  CPPFLAGS=$CPPFLAGS
  CFLAGS=$CFLAGS
@@@ -391,30 -285,7 +391,30 @@@ int ff_decode_frame_props(AVCodecContex
   */
  AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx);
  
- #if defined(_MSC_VER) && CONFIG_SHARED
 +int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type);
 +
 +/**
 + * Check AVFrame for A53 side data and allocate and fill SEI message with A53 info
 + *
 + * @param frame      Raw frame to get A53 side data from
 + * @param prefix_len Number of bytes to allocate before SEI message
 + * @param data       Pointer to a variable to store allocated memory
 + *                   Upon return the variable will hold NULL on error or if frame has no A53 info.
 + *                   Otherwise it will point to prefix_len uninitialized bytes followed by
 + *                   *sei_size SEI message
 + * @param sei_size   Pointer to a variable to store generated SEI message length
 + * @return           Zero on success, negative error code on failure
 + */
 +int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
 +                     void **data, size_t *sei_size);
 +
 +/**
 + * Get an estimated video bitrate based on frame size, frame rate and coded
 + * bits per pixel.
 + */
 +int64_t ff_guess_coded_bitrate(AVCodecContext *avctx);
 +
+ #if defined(_WIN32) && CONFIG_SHARED
  #ifdef BUILDING_avcodec
  #    define av_export_avcodec __declspec(dllexport)
  #else
  #endif
  #endif
  
- #if defined(_MSC_VER) && CONFIG_SHARED
++#if defined(_WIN32) && CONFIG_SHARED
 +#ifdef BUILDING_avutil
 +#    define av_export_avutil __declspec(dllexport)
 +#else
 +#    define av_export_avutil __declspec(dllimport)
 +#endif
 +#else
 +#    define av_export_avutil
 +#endif
 +
  #if HAVE_PRAGMA_DEPRECATED
 -#    if defined(__ICL)
 +#    if defined(__ICL) || defined (__INTEL_COMPILER)
  #        define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478))
  #        define FF_ENABLE_DEPRECATION_WARNINGS  __pragma(warning(pop))
  #    elif defined(_MSC_VER)