Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[haxe 4.3.4] build errors #11878

Open
acarioni opened this issue Dec 12, 2024 · 10 comments
Open

[haxe 4.3.4] build errors #11878

acarioni opened this issue Dec 12, 2024 · 10 comments

Comments

@acarioni
Copy link

I'm trying to compile Haxe 4.3.4 on a Mac M2 running Sequoia 15.1.1 and OCaml 5.2.1.
I've encountered some issues along the way, but I've managed to resolve most of them (#11787 #10679 #11874).

Now, I'm facing the following errors:

dune build --workspace dune-workspace.dev src-prebuild/prebuild.exe
_build/default/src-prebuild/prebuild.exe libparams -cclib -lpcre2-8 -cclib -lz -cclib -lmbedtls -cclib -lmbedx509 -cclib -lmbedcrypto -cclib '-framework Security -framework CoreFoundation' > lib.sexp
_build/default/src-prebuild/prebuild.exe version "0" "b4.3.4" "dc1a43dc5" > src/compiler/version.ml
dune build --workspace dune-workspace.dev src/haxe.exe
File "libs/pcre2/dune", line 7, characters 9-20:
7 |             (names pcre2_stubs))
             ^^^^^^^^^^^
pcre2_stubs.c:57:10: fatal error: 'pcre2.h' file not found
   57 | #include <pcre2.h>
      |          ^~~~~~~~~
1 error generated.
File "libs/mbedtls/dune", line 7, characters 9-22:
7 |             (names mbedtls_stubs))
             ^^^^^^^^^^^^^
mbedtls_stubs.c:21:10: fatal error: 'mbedtls/debug.h' file not found
   21 | #include "mbedtls/debug.h"
      |          ^~~~~~~~~~~~~~~~~

I've installed both pcre2 and mbedtls@2 through Homebrew.
Here are the installation details:

==> pcre2: stable 10.44 (bottled), HEAD
Perl compatible regular expressions library with a new API
https://www.pcre.org/
Installed
/opt/homebrew/Cellar/pcre2/10.44 (237 files, 6.3MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-08-27 at 09:21:42
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/pcre2.rb
==> mbedtls@2: stable 2.28.9 (bottled), HEAD [keg-only]
Cryptographic & SSL/TLS library
https://tls.mbed.org/
Installed
/opt/homebrew/Cellar/mbedtls@2/2.28.9 (188 files, 8.3MB)
  Poured from bottle using the formulae.brew.sh API on 2024-12-12 at 08:56:51
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/m/[email protected]

I've also tried setting the LDFLAGS and CPPFLAGS variables to the library locations, but it seems the build script does not use them.

@tobil4sk
Copy link
Member

What exactly did you put in the LDFLAGS/CPPFLAGS?

On intel macs, homebrew installs to /usr/local which is a default include/library search path, but now on apple silicon macs it installs to /opt/homebrew/ which isn't in the default paths.

You may need to modify the dune files in a similar way to: #11195

@acarioni
Copy link
Author

On my machine, pcre2 and mbedtls@2 are installed at /opt/homebrew/opt. So I've set LDFLAGS/CPPFLAGS accordingly.
But it seems these variables are being ignored by the Haxe build script.

@acarioni
Copy link
Author

I modified the dune configuration files libs/mbedtls/dune and libs/pcre2/dune as suggested in #11195.
Here are the updated files:

(include_subdirs no)

(library
	(name mbedtls)
	(foreign_stubs
		(language c)
		(names mbedtls_stubs)
		(flags -I/opt/homebrew/opt/mbedtls@2/include))
	(c_library_flags (-L/opt/homebrew/opt/mbedtls@2/lib))
	(wrapped false)
)
(include_subdirs no)

(library
	(name pcre2)
	(foreign_stubs
		(language c)
		(names pcre2_stubs)
		(flags -I/opt/homebrew/opt/pcre2/include))
	(c_library_flags (-L/opt/homebrew/opt/pcre2/lib))
	(wrapped false)
)

Now the build script can find the libraries.
However, a new error has popped up:

dune build --workspace dune-workspace.dev src-prebuild/prebuild.exe
_build/default/src-prebuild/prebuild.exe libparams -cclib -lpcre2-8 -cclib -lz -cclib -lmbedtls -cclib -lmbedx509 -cclib -lmbedcrypto -cclib '-framework Security -framework CoreFoundation' > lib.sexp
_build/default/src-prebuild/prebuild.exe version "0" "b4.3.4" "dc1a43dc5" > src/compiler/version.ml
dune build --workspace dune-workspace.dev src/haxe.exe
cp -f _build/default/src/haxe.exe ./"haxe"
(cd /Volumes/T7/git/haxe/extra/haxelib_src && /Volumes/T7/git/haxe/haxe client.hxml && nekotools boot run.n)
/bin/sh: line 1: 62839 Segmentation fault: 11  nekotools boot run.n
make: *** [haxelib] Error 139

@tobil4sk
Copy link
Member

Do you have neko installed on your system? If so, how did you install it?

@acarioni
Copy link
Author

Well, I fixed the problem by setting the NEKOPATH variable (export NEKOPATH="/opt/homebrew/lib/neko" ).
However, I found this setting by chance while running brew info neko, as it is not mentioned in the build instructions.
Now the build seems to be going fine.
Thanks to @tobil4sk for the help.

@tobil4sk
Copy link
Member

It may be best to keep this issue open until a better solution is found, as I suspect building from development would give the same errors.

@Simn Simn reopened this Dec 13, 2024
@tobil4sk
Copy link
Member

Another way to solve this without modifying any build files is to set the following environment variables:

export C_INCLUDE_PATH=$(brew --prefix zlib)/include:$(brew --prefix)/include
export LIBRARY_PATH=$(brew --prefix zlib)/lib:$(brew --prefix)/lib

Zlib is "keg-only" (not linked in the global brew prefix) to avoid interfering with the system version, which is why the zlib paths have to be added explicitly. If you are compiling a 4.3.x build, that doesn't support mbedtls 3 yet so you have to also add $(brew --prefix mbedtls@2) entries like zlib.

I was also considering whether this should be handled by conf-mbedtls and conf-libpcre2-8, but it looks like the opam advice is against that: ocaml/opam-repository#6271

@acarioni
Copy link
Author

Perhaps you meant pcre2 rather than zlib.

@tobil4sk
Copy link
Member

Is there an issue with pcre2 still?

Both zlib and pcre2 are required to build haxe. There was no error before because it was building with the system version, I'm not sure if that's ok or if that might cause issues.

pcre2 should be linked to the main brew prefix so adding $(brew --prefix)/include and $(brew --prefix)/lib should be enough to get it working, or are there still issues?

@acarioni
Copy link
Author

No, I don't have any problems. However, since this issue mentions pcre2 and mbedtls but not zlib, I mistakenly assumed you were referring to pcre2.

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

No branches or pull requests

3 participants