VOGONS


First post, by nahum

User metadata
Rank Newbie
Rank
Newbie

RE: ffmpeg-4.4
DJGPP CROSS COMPILER, GCC v12.2.0
Host: Macbook Pro, macOS Monterey
link
link

"DJGPP Cross Compiler 12.2.0 Fails to Recognize Parameters in FFmpeg Source Code"
Hi,
I am using the referenced DJGPP cross compiler 12.2.0, to build the FFmpeg source code, and it's failing to recognize certain parameters and the script I used to build FFmpeg SRC follows:

#!/usr/bin/env bash

# Path to DJGPP cross compiler
export DJGPP_PREFIX="/Users/owner/djcc"
# export DJGPP_PREFIX=${DJGPP_PREFIX-/Users/owner/djcc}
export DJGPP_PREFIX2=${DJGPP_PREFIX2-/Users/owner/ffcc}
# export
DJGPP_PREFIX3=${DJGPP_PREFIX3-/Users/owner/Documents/DOSBox/NET/watt}
# system path
export PATH="$DJGPP_PREFIX/bin:$PATH"

# Your cross compilation target
TARGET_ARCH="$DJGPP_PREFIX/bin/i586-pc-msdosdjgpp"
# set C_INCLUDE_PATH environment variable
export C_INCLUDE_PATH="#DJGPP_PREFIX/i586-pc-msdosdjgpp/sys-include"

# Download FFmpeg source code
FFMPEG_VERSION="4.4"
FFMPEG_ARCHIVE="https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz"
FFMPEG_SOURCE_DIR="ffmpeg-${FFMPEG_VERSION}"

# Download FFmpeg source
echo "Downloading FFmpeg source..."
wget -c "$FFMPEG_ARCHIVE" || exit 1
tar -xf "ffmpeg-${FFMPEG_VERSION}.tar.gz" || exit 1
cd "$FFMPEG_SOURCE_DIR" || exit 1

# clean debri
gmake clean

# Redirect both stdout and stderr to separate .err files
exec > >(tee -ia gcca.txt) 2> >(tee -ia gcc_err.err >&2)

# Configure FFmpeg for cross-compilation
echo "Configuring FFmpeg for cross-compilation..."
./configure --enable-cross-compile \
--prefix="$DJGPP_PREFIX2" \
--target-os=ms-dos \
--arch=i486 \
--cross-prefix="$TARGET_ARCH-" \
--extra-cflags="-I$DJGPP_PREFIX/i586-pc-msdosdjgpp/sys-include -I$DJGPP_PREFIX/include -I$DJGPP_PREFIX3/inc2 -I$DJGPP_PREFIX3/inc3" \
--extra-ldflags="-L$DJGPP_PREFIX/i586-pc-msdosdjgpp/lib -L$DJGPP_PREFIX/lib -L$DJGPP_PREFIX3/lib2 -L$DJGPP_PREFIX3/lib3" \
--enable-debug \
--disable-shared \
--enable-static \
--disable-doc \
--disable-programs \
|| exit 1

# Compile a hello world program for testing
echo "Compiling hello world program for testing..."
cat > helloai.c <<EOF
#include <stdio.h>

int main() {
printf("Hello, world!\\n");
return 0;
}
EOF

Show last 9 lines
"$TARGET_ARCH-gcc" helloai.c -o helloai || exit 1

# Compile FFmpeg
echo "Compiling FFmpeg..."
gmake CC="$DJGPP_PREFIX/bin/i586-pc-msdosdjgpp-gcc" || exit 1
# gmake install || exit 1

echo "Compilation complete."

The following 36 issues surfaced compiling FFmpeg DJGPP 'make' cross compile, stating, "error: declaration for parameter 'XX_XXXX_XX_XXXX' but no such parameter:".

1) 'ff_log_net_error' […]
Show full quote

1) 'ff_log_net_error'

2) 'ff_socket'

3) 'ff_http_match_no_proxy'

4) 'ff_listen_connect'

5) 'ff_accept'

6) 'ff_listen'

7) 'ff_listen_bind'

😎 'ff_is_multicast_address'

9) 'ff_gai_strerror'

10)'ff_getnameinfo'

11) 'ff_freeaddrinfo'

12) 'ff_getaddrinfo'

13) 'sockaddr_union'

14) 'ff_network_sleep_interruptible'

15) 'ff_network_wait_fd_timeout'

16) 'ff_network_wait_fd'

17) 'ff_tls_deinit'

18) 'ff_tls_init'

19) 'ff_network_close'

20) 'ff_network_init'

21) 'ff_socket_nonblock'

22) 'ff_connect_parallel'

23) 'ff_log_net_error'

24) 'ff_socket'

25) 'ff_http_match_no_proxy'

26) 'ff_listen_connect'

27) 'ff_accept'

28) 'ff_listen'

29)'ff_listen_bind'

30) 'ff_is_multicast_address'

31) 'ff_gai_strerror'

32) 'ff_getnameinfo'

33) 'ff_freeaddrinfo'

34) 'ff_getaddrinfo'

35) 'sockaddr_union'

36) 'ff_network_sleep_interruptible'

The 'no such parameter', observed in 'libavformat/network.h', has now shown up in
'/libavformat/avio.c':

libavformat/avio.c:57:23: error: declaration for parameter 'options' but no such parameter

libavformat/avio.c:64:15: error: declaration for parameter 'ffurl_context_class' but no such parameter

// libavformat/avio.c
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/avassert.h"
#include "os_support.h"
#include "avformat.h"
#include "internal.h"
#if CONFIG_NETWORK
#include "network.h"
#endif
#include "url.h"

/** @name Logging context. */
/*@{*/
static const char *urlcontext_to_name(void *ptr)
{
URLContext *h = (URLContext *)ptr;
if (h->prot)
return h->prot->name;
else
return "NULL";
}

static void *urlcontext_child_next(void *obj, void *prev)
{
URLContext *h = obj;
if (!prev && h->priv_data && h->prot->priv_data_class)
return h->priv_data;
return NULL;
}

#define OFFSET(x) offsetof(URLContext,x)
#define E AV_OPT_FLAG_ENCODING_PARAM
#define D AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = { // L57:23
{"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
{"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
{"rw_timeout", "Timeout for IO operations (in microseconds)", offsetof(URLContext, rw_timeout), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_DECODING_PARAM },
{ NULL }
};

const AVClass ffurl_context_class = { // L64:15
.class_name = "URLContext",
.item_name = urlcontext_to_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
.child_next = urlcontext_child_next,
#if FF_API_CHILD_CLASS_NEXT
.child_class_next = ff_urlcontext_child_class_next,
#endif
.child_class_iterate = ff_urlcontext_child_class_iterate,
};
/*@}*/

This same source code compiled on mac's clang compiler, however, GCC cross compiler is a different story. Therefore, please explain the root cause inhibiting make build of FFmpeg, thanks!

Reply 2 of 6, by elszgensa

User metadata
Rank Member
Rank
Member

no idea why you deem it necessary to work with three prefixes, yet not pass even a single one of those as sysroot... fwiw this:

#!/bin/bash

set -e

export DJGPP_PREFIX="${HOME}/x-tools/i586-pc-msdosdjgpp"
TARGET_ARCH="${DJGPP_PREFIX}/bin/i586-pc-msdosdjgpp"
export PATH="${DJGPP_PREFIX}/bin:$PATH"

FFMPEG_VERSION="4.4"
FFMPEG_ARCHIVE="https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz"
FFMPEG_SOURCE_DIR="ffmpeg-${FFMPEG_VERSION}"

wget -c "$FFMPEG_ARCHIVE"
rm -rf "$FFMPEG_SOURCE_DIR"
tar -xf "ffmpeg-${FFMPEG_VERSION}.tar.gz"
cd "$FFMPEG_SOURCE_DIR"

./configure \
--enable-cross-compile \
--cross-prefix="${TARGET_ARCH}-" \
--sysroot="${DJGPP_PREFIX}" \
--arch=i486 \
--target-os=ms-dos \
--extra-cflags="-w" \
--disable-doc \

make V=1 -j$(nproc)

...works for me.

To work around djgpp's float limits not being defined as constants (which is not to spec) I did something hacky to its headers:

jank
--- a/i586-pc-msdosdjgpp/sys-include/float.h	2015-05-02 06:31:45.000000000 +0200
+++ b/i586-pc-msdosdjgpp/sys-include/float.h 2024-02-28 14:39:25.578626816 +0100
@@ -15,10 +15,10 @@
#define FLT_DIG 6
#define FLT_EPSILON __dj_float_epsilon
#define FLT_MANT_DIG 24
-#define FLT_MAX __dj_float_max
+#define FLT_MAX 666
#define FLT_MAX_10_EXP 38
#define FLT_MAX_EXP 128
-#define FLT_MIN __dj_float_min
+#define FLT_MIN (-666)
#define FLT_MIN_10_EXP (-37)
#define FLT_MIN_EXP (-125)
#define FLT_RADIX 2
@@ -31,10 +31,10 @@
#define DBL_DIG 15
#define DBL_EPSILON __dj_double_epsilon
#define DBL_MANT_DIG 53
-#define DBL_MAX __dj_double_max
+#define DBL_MAX 666
#define DBL_MAX_10_EXP 308
#define DBL_MAX_EXP 1024
-#define DBL_MIN __dj_double_min
+#define DBL_MIN (-666)
#define DBL_MIN_10_EXP (-307)
#define DBL_MIN_EXP (-1021)

...which is not a proper solution but will at least get things moving.

Reply 3 of 6, by nahum

User metadata
Rank Newbie
Rank
Newbie
elszgensa wrote on 2024-02-28, 14:16:

To work around djgpp's float limits not being defined as constants (which is not to spec) I did something hacky to its headers:

jank
--- a/i586-pc-msdosdjgpp/sys-include/float.h	2015-05-02 06:31:45.000000000 +0200
+++ b/i586-pc-msdosdjgpp/sys-include/float.h 2024-02-28 14:39:25.578626816 +0100
@@ -15,10 +15,10 @@
#define FLT_DIG 6
#define FLT_EPSILON __dj_float_epsilon
#define FLT_MANT_DIG 24
-#define FLT_MAX __dj_float_max
+#define FLT_MAX 666
#define FLT_MAX_10_EXP 38
#define FLT_MAX_EXP 128
-#define FLT_MIN __dj_float_min
+#define FLT_MIN (-666)
#define FLT_MIN_10_EXP (-37)
#define FLT_MIN_EXP (-125)
#define FLT_RADIX 2
@@ -31,10 +31,10 @@
#define DBL_DIG 15
#define DBL_EPSILON __dj_double_epsilon
#define DBL_MANT_DIG 53
-#define DBL_MAX __dj_double_max
+#define DBL_MAX 666
#define DBL_MAX_10_EXP 308
#define DBL_MAX_EXP 1024
-#define DBL_MIN __dj_double_min
+#define DBL_MIN (-666)
#define DBL_MIN_10_EXP (-307)
#define DBL_MIN_EXP (-1021)

...which is not a proper solution but will at least get things moving.

elszgensa,
Using this quick-n-dirty work around did build ffmpeg, ffprobe executables and no sign of ffplay.
ffmpeg help screen did display ok, however, no functionality, only the following issues:

ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 12.2.0 (GCC) configuration: --enable-cross-c […]
Show full quote

ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 12.2.0 (GCC)
configuration: --enable-cross-compile --cross-prefix=/Users/owner/djcc3/bin/i586-pc-msdosdjgpp- --sysroot=/Users/owner/djcc3 --arch=i486 --target-os=ms-dos --extra-cflags=-w --disable-doc
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
[h264 @ 1a84f98] Warning: not compiled with thread support, using thread emulation
[aac @ 1a85bb0] Warning: not compiled with thread support, using thread emulation
Exiting due to signal SIGILL
Invalid Opcode at eip=00e39b0c
eax=00000000 ebx=01abde64 ecx=00000000 edx=00000000 esi=00000000 edi=01abdf9b
ebp=01abde78 esp=01a827c0 program=C:\1RECV\FFMPEG.EXE
cs: sel=00a7 base=00400000 limit=01ceffff
ds: sel=00af base=00400000 limit=01ceffff
es: sel=00af base=00400000 limit=01ceffff
fs: sel=008f base=00004ae0 limit=0000ffff
gs: sel=00bf base=00000000 limit=0010ffff
ss: sel=00af base=00400000 limit=01ceffff
App stack: [01a83210..01a03210] Exceptn stack: [01a0292c..01a009ec]

Call frame traceback EIPs:
0x00e39b0c

Any comments or suggestions interpreting signal SIGILL and its work around, would be appreciated. Thanks in advance!

Reply 4 of 6, by elszgensa

User metadata
Rank Member
Rank
Member

By "get things moving" I meant solely in the context of getting stuff shoved through the compiler (to see if any other issues crop up at this point), not that the end result would work. You still need to fix that properly.

Maybe try some less complex codecs than h264+aac to start with. In fact, I'd recommend entirely configuring out anything you don't need for basic functionality, features as well as optimizations (e.g. --disable-asm), and build from there.

ffplay requires SDL so you're gonna have to provide that too. There's a readme only for Watcom, but the config scripts also have a few places handling DJGPP already, so I have no idea how much effort that'd be. I haven't tried.

Afraid that's all you're gonna get from me, I don't really have the time to deep dive into this.

Reply 5 of 6, by nahum

User metadata
Rank Newbie
Rank
Newbie
elszgensa wrote on 2024-03-01, 13:49:

ffplay requires SDL so you're gonna have to provide that too.

Hi,
The latest FFmpeg DJGPP GCC v12.2.0 cross compiler build works like a charm w/o any tweaks, so it can only get better!
If ffplay requires SDL, can DJGPP cross compiler handle its build, using the following Hotlinks, etc., Thanks in advance!

link

link

Reply 6 of 6, by megatron-uk

User metadata
Rank Oldbie
Rank
Oldbie

Have you actually looked yourself at whether SDL 2 (which ffmpeg requires) supports DOS output targets?

People have been wanting this for years and years:

https://discourse.libsdl.org/t/porting-sdl-to-dos/27361

My collection database and technical wiki:
https://www.target-earth.net