Skip to content

Add FreeBSD support#670

Open
vkrivopalov wants to merge 1 commit intoTelegramMessenger:masterfrom
vkrivopalov:freebsd-support
Open

Add FreeBSD support#670
vkrivopalov wants to merge 1 commit intoTelegramMessenger:masterfrom
vkrivopalov:freebsd-support

Conversation

@vkrivopalov
Copy link
Copy Markdown

Port MTProxy to FreeBSD by addressing Linux-specific dependencies:

Build system (Makefile):

  • Add FreeBSD detection and platform-specific CFLAGS/LDFLAGS
  • Link against libepoll-shim for epoll compatibility layer
  • Link against libexecinfo for backtrace support
  • Remove -lrt and -rdynamic (not needed on FreeBSD)

Signal handling:

  • Add missing signal.h include in mtproto-proxy.c
  • Adapt SIGRTMAX handling for FreeBSD (uses different signal range)
  • Wrap SIGPOLL usage (not available on FreeBSD)

Threading and synchronization:

  • Replace Linux futex syscalls with FreeBSD _umtx_op()
  • Replace SYS_gettid with thr_self() for thread identification
  • Replace glibc-specific drand48_r/srand48_r with mutex-protected standard drand48/srand48 functions
  • Wrap struct drand48_data with #ifdef linux

Socket options:

  • Wrap TCP_WINDOW_CLAMP (Linux-specific)
  • Wrap TCP_QUICKACK (Linux-specific)
  • Wrap IP_RECVERR/SOL_IP (Linux-specific)

Header compatibility:

  • Disable _XOPEN_SOURCE on FreeBSD (conflicts with IPv6 definitions)
  • Add sys/socket.h before netinet/in.h for struct sockaddr_in6
  • Add socket headers to resolver.c
  • Wrap sys/io.h include (Linux-specific)
  • Undef close macro from libepoll-shim to avoid struct member conflict

Compiler compatibility:

  • Add clang-compatible intrinsic macros for SIMD operations in crc32.c (maps GCC _builtin_ia32* to standard Intel intrinsics)

Requires: libepoll-shim package (pkg install libepoll-shim)

Use 'gmake' (pkg install gmake) to stay compatible with GNU-style Makefile.

Closes: #16 #331

Port MTProxy to FreeBSD by addressing Linux-specific dependencies:

Build system (Makefile):
- Add FreeBSD detection and platform-specific CFLAGS/LDFLAGS
- Link against libepoll-shim for epoll compatibility layer
- Link against libexecinfo for backtrace support
- Remove -lrt and -rdynamic (not needed on FreeBSD)

Signal handling:
- Add missing signal.h include in mtproto-proxy.c
- Adapt SIGRTMAX handling for FreeBSD (uses different signal range)
- Wrap SIGPOLL usage (not available on FreeBSD)

Threading and synchronization:
- Replace Linux futex syscalls with FreeBSD _umtx_op()
- Replace SYS_gettid with thr_self() for thread identification
- Replace glibc-specific drand48_r/srand48_r with mutex-protected
  standard drand48/srand48 functions
- Wrap struct drand48_data with #ifdef __linux__

Socket options:
- Wrap TCP_WINDOW_CLAMP (Linux-specific)
- Wrap TCP_QUICKACK (Linux-specific)
- Wrap IP_RECVERR/SOL_IP (Linux-specific)

Header compatibility:
- Disable _XOPEN_SOURCE on FreeBSD (conflicts with IPv6 definitions)
- Add sys/socket.h before netinet/in.h for struct sockaddr_in6
- Add socket headers to resolver.c
- Wrap sys/io.h include (Linux-specific)
- Undef close macro from libepoll-shim to avoid struct member conflict

Compiler compatibility:
- Add clang-compatible intrinsic macros for SIMD operations in crc32.c
  (maps GCC __builtin_ia32_* to standard Intel intrinsics)

Requires: libepoll-shim package (pkg install libepoll-shim)

Use 'gmake' (pkg install gmake) to stay compatible with GNU-style
Makefile.

Signed-off-by: Vladimir Krivopalov <vladimir.krivopalov@gmail.com>
@pesterevvladislav
Copy link
Copy Markdown

pesterevvladislav commented Apr 1, 2026

Hi! How do I build this on FreeBSD? Just use gmake as always?

@pesterevvladislav
Copy link
Copy Markdown

pesterevvladislav commented Apr 1, 2026

I tried to build using make, gmake, but I still catch errors in FreeBSD:

~/src/MTProxy  (git)-[master]-$ doas pkg install gmake
Updating FreeBSD repository catalogue...
Fetching data: 100%   10 MiB   5.4 M/s    00:02    
Processing entries:   0%
Newer FreeBSD version for package zycore-c:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1403000
- running userland: 1401000
Ignore the mismatch and continue? [y/N]: y
Processing entries: 100%
FreeBSD repository update completed. 36543 packages processed.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	gmake: 4.4.1

Number of packages to be installed: 1

The process will require 2 MiB more space.
487 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching gmake-4.4.1: 100%  487 KiB 498.9 k/s    00:01    
Checking integrity... done (0 conflicting)
[1/1] Installing gmake-4.4.1...
[1/1] Extracting gmake-4.4.1: 100%
~/src/MTProxy  (git)-[master]-$ gmake
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fno-strict-overflow -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -iquote common -iquote . -c -MP -MD -MF dep/mtproto/mtproto-proxy.d -MQ objs/mtproto/mtproto-proxy.o -o objs/mtproto/mtproto-proxy.o mtproto/mtproto-proxy.c
cc: warning: argument unused during compilation: '-fno-strict-overflow' [-Wunused-command-line-argument]
In file included from mtproto/mtproto-proxy.c:53:
In file included from ./net/net-tcp-connections.h:28:
In file included from ./net/net-connections.h:34:
./jobs/jobs.h:235:23: error: field has incomplete type 'struct drand48_data'
  235 |   struct drand48_data rand_data;
      |                       ^
./jobs/jobs.h:235:10: note: forward declaration of 'struct drand48_data'
  235 |   struct drand48_data rand_data;
      |          ^
mtproto/mtproto-proxy.c:2006:9: warning: call to undeclared function 'kill'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 2006 |         kill (pids[i], SIGKILL);
      |         ^
mtproto/mtproto-proxy.c:2006:24: error: use of undeclared identifier 'SIGKILL'
 2006 |         kill (pids[i], SIGKILL);
      |                        ^
mtproto/mtproto-proxy.c:2018:7: warning: call to undeclared function 'kill'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 2018 |       kill (pids[i], signal);
      |       ^
mtproto/mtproto-proxy.c:2037:26: error: use of undeclared identifier 'SIGTERM'
 2037 |           kill_children (SIGTERM);
      |                          ^
mtproto/mtproto-proxy.c:2045:24: error: use of undeclared identifier 'SIGTERM'
 2045 |         kill_children (SIGTERM);
      |                        ^
mtproto/mtproto-proxy.c:2101:51: error: use of undeclared identifier 'TCP_WINDOW_CLAMP'
 2101 |         if (setsockopt (http_sfd[i], IPPROTO_TCP, TCP_WINDOW_CLAMP, &window_clamp, 4) < 0) {
      |                                                   ^
mtproto/mtproto-proxy.c:2117:20: error: use of undeclared identifier 'SIGUSR1'
 2117 |     kill_children (SIGUSR1);
      |                    ^
mtproto/mtproto-proxy.c:2341:31: error: use of undeclared identifier 'SIGTERM'
 2341 |     if (signal_check_pending (SIGTERM)) {
      |                               ^
mtproto/mtproto-proxy.c:2342:22: error: use of undeclared identifier 'SIGTERM'
 2342 |       kill_children (SIGTERM);
      |                      ^
mtproto/mtproto-proxy.c:2369:55: error: use of undeclared identifier 'SIGCHLD'
 2369 |   mtproto_front_functions.allowed_signals |= SIG2INT (SIGCHLD);
      |                                                       ^
mtproto/mtproto-proxy.c:2369:55: error: use of undeclared identifier 'SIGCHLD'
mtproto/mtproto-proxy.c:2370:43: error: use of undeclared identifier 'SIGCHLD'
 2370 |   mtproto_front_functions.signal_handlers[SIGCHLD] = on_child_termination;
      |                                           ^
mtproto/mtproto-proxy.c:2371:43: error: use of undeclared identifier 'SIGUSR1'
 2371 |   mtproto_front_functions.signal_handlers[SIGUSR1] = mtfront_sigusr1_handler;
      |                                           ^
2 warnings and 12 errors generated.
gmake: *** [Makefile:86: objs/mtproto/mtproto-proxy.o] Error 1
~/src/MTProxy  (git)-[master]-$ make
make: "/home/dev/src/MTProxy/Makefile" line 5: Unknown modifier ""%H""
make: "/home/dev/src/MTProxy/Makefile" line 8: Invalid line type
make: "/home/dev/src/MTProxy/Makefile" line 10: Invalid line type
make: "/home/dev/src/MTProxy/Makefile" line 11: Invalid line type
make: "/home/dev/src/MTProxy/Makefile" line 13: Invalid line type
make: Fatal errors encountered -- cannot continue
make: stopped in /home/dev/src/MTProxy

@pesterevvladislav
Copy link
Copy Markdown

pesterevvladislav commented Apr 1, 2026

После установки libepoll-shim сбилдилось
Successfully built after installation of package libepoll-shim:

~/src/MTProxy  (git)-[master]-$ gmake
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-events.d -MQ objs/net/net-events.o -o objs/net/net-events.o net/net-events.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-msg.d -MQ objs/net/net-msg.o -o objs/net/net-msg.o net/net-msg.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-msg-buffers.d -MQ objs/net/net-msg-buffers.o -o objs/net/net-msg-buffers.o net/net-msg-buffers.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-config.d -MQ objs/net/net-config.o -o objs/net/net-config.o net/net-config.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-crypto-aes.d -MQ objs/net/net-crypto-aes.o -o objs/net/net-crypto-aes.o net/net-crypto-aes.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-crypto-dh.d -MQ objs/net/net-crypto-dh.o -o objs/net/net-crypto-dh.o net/net-crypto-dh.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-timers.d -MQ objs/net/net-timers.o -o objs/net/net-timers.o net/net-timers.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-connections.d -MQ objs/net/net-connections.o -o objs/net/net-connections.o net/net-connections.c
net/net-connections.c:337:20: warning: unused function 'cond_disable_qack' [-Wunused-function]
  337 | static inline void cond_disable_qack (socket_connection_job_t C) {
      |                    ^~~~~~~~~~~~~~~~~
1 warning generated.
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-rpc-targets.d -MQ objs/net/net-rpc-targets.o -o objs/net/net-rpc-targets.o net/net-rpc-targets.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-tcp-connections.d -MQ objs/net/net-tcp-connections.o -o objs/net/net-tcp-connections.o net/net-tcp-connections.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-tcp-rpc-common.d -MQ objs/net/net-tcp-rpc-common.o -o objs/net/net-tcp-rpc-common.o net/net-tcp-rpc-common.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-tcp-rpc-client.d -MQ objs/net/net-tcp-rpc-client.o -o objs/net/net-tcp-rpc-client.o net/net-tcp-rpc-client.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-tcp-rpc-server.d -MQ objs/net/net-tcp-rpc-server.o -o objs/net/net-tcp-rpc-server.o net/net-tcp-rpc-server.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-http-server.d -MQ objs/net/net-http-server.o -o objs/net/net-http-server.o net/net-http-server.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/tl-parse.d -MQ objs/common/tl-parse.o -o objs/common/tl-parse.o common/tl-parse.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/common-stats.d -MQ objs/common/common-stats.o -o objs/common/common-stats.o common/common-stats.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/engine/engine.d -MQ objs/engine/engine.o -o objs/engine/engine.o engine/engine.c
engine/engine.c:459:7: warning: variable 'i' set but not used [-Wunused-but-set-variable]
  459 |   int i;
      |       ^
1 warning generated.
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/engine/engine-signals.d -MQ objs/engine/engine-signals.o -o objs/engine/engine-signals.o engine/engine-signals.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/engine/engine-net.d -MQ objs/engine/engine-net.o -o objs/engine/engine-net.o engine/engine-net.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/engine/engine-rpc.d -MQ objs/engine/engine-rpc.o -o objs/engine/engine-rpc.o engine/engine-rpc.c
engine/engine-rpc.c:258:36: warning: unused function 'do_skip_function_any' [-Wunused-function]
  258 | static inline struct paramed_type *do_skip_function_any (struct tl_in_state *tlio_in) {
      |                                    ^~~~~~~~~~~~~~~~~~~~
engine/engine-rpc.c:263:36: warning: unused function 'do_fetch_function_any' [-Wunused-function]
  263 | static inline struct paramed_type *do_fetch_function_any (struct tl_in_state *tlio_in) {
      |                                    ^~~~~~~~~~~~~~~~~~~~~
engine/engine-rpc.c:269:19: warning: unused function 'do_fetch_type_any' [-Wunused-function]
  269 | static inline int do_fetch_type_any (struct tl_in_state *tlio_in, struct paramed_type *P) {
      |                   ^~~~~~~~~~~~~~~~~
3 warnings generated.
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/engine/engine-rpc-common.d -MQ objs/engine/engine-rpc-common.o -o objs/engine/engine-rpc-common.o engine/engine-rpc-common.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-thread.d -MQ objs/net/net-thread.o -o objs/net/net-thread.o net/net-thread.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/net/net-stats.d -MQ objs/net/net-stats.o -o objs/net/net-stats.o net/net-stats.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/proc-stat.d -MQ objs/common/proc-stat.o -o objs/common/proc-stat.o common/proc-stat.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/kprintf.d -MQ objs/common/kprintf.o -o objs/common/kprintf.o common/kprintf.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/precise-time.d -MQ objs/common/precise-time.o -o objs/common/precise-time.o common/precise-time.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/cpuid.d -MQ objs/common/cpuid.o -o objs/common/cpuid.o common/cpuid.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/server-functions.d -MQ objs/common/server-functions.o -o objs/common/server-functions.o common/server-functions.c
cc  -O3 -std=gnu11 -Wall -Wno-array-bounds -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fwrapv -DAES=1 -DCOMMIT=\"cafc3380a81671579ce366d0594b9a8e450827e9\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/local/include/libepoll-shim -fpic -iquote common -iquote . -c -MP -MD -MF dep/common/crc32.d -MQ objs/common/crc32.o -o objs/common/crc32.o common/crc32.c
rm -f objs/lib/libkdb.a && ar rcs objs/lib/libkdb.a objs/common/crc32c.o objs/common/pid.o objs/common/sha1.o objs/common/sha256.o objs/common/md5.o objs/common/resolver.o objs/common/parse-config.o objs/crypto/aesni256.o objs/jobs/jobs.o objs/common/mp-queue.o objs/net/net-events.o objs/net/net-msg.o objs/net/net-msg-buffers.o objs/net/net-config.o objs/net/net-crypto-aes.o objs/net/net-crypto-dh.o objs/net/net-timers.o objs/net/net-connections.o objs/net/net-rpc-targets.o objs/net/net-tcp-connections.o objs/net/net-tcp-rpc-common.o objs/net/net-tcp-rpc-client.o objs/net/net-tcp-rpc-server.o objs/net/net-http-server.o objs/common/tl-parse.o objs/common/common-stats.o objs/engine/engine.o objs/engine/engine-signals.o objs/engine/engine-net.o objs/engine/engine-rpc.o objs/engine/engine-rpc-common.o objs/net/net-thread.o objs/net/net-stats.o objs/common/proc-stat.o objs/common/kprintf.o objs/common/precise-time.o objs/common/cpuid.o objs/common/server-functions.o objs/common/crc32.o
cc -o objs/bin/mtproto-proxy objs/mtproto/mtproto-proxy.o objs/mtproto/mtproto-config.o objs/net/net-tcp-rpc-ext-server.o objs/lib/libkdb.a objs/lib/libkdb.a  -ggdb -L/usr/local/lib -lm -lcrypto -lz -lpthread -lepoll-shim -lexecinfo

@pesterevvladislav
Copy link
Copy Markdown

My result in FreeBSD:
mtproto-proxy.zip

~ $ uname -a
FreeBSD 58325832.xyz 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64

@pesterevvladislav
Copy link
Copy Markdown

pesterevvladislav commented Apr 1, 2026

Еще баг нашел через LLM:
Замени в MTProxy/common/pid.c строки 41-43:

    int p = getpid ();
    assert (!(p & 0xffff0000));
    PID.pid = p;

на:

    int p = getpid ();
#ifdef __FreeBSD__
    PID.pid = p & 0xffff;
#else
    assert (!(p & 0xffff0000));
    PID.pid = p;
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build error on Solaris

3 participants