Skip to content

Conversation

@HCLJason
Copy link
Contributor

This does introduce a dependency on system zilb to resolve a duplicate symbols issue. There's an open issue in freetype to fix this.

https://gitlab.freedesktop.org/freetype/freetype/-/issues/1146

The changes to the srcs list come from the CMakeLists file.

target=os.path.join('freetype2'))

with open(os.path.join(source_path, 'include', 'freetype', 'config', 'ftoption.h'), 'a') as ftheader:
ftheader.write('#define FT_CONFIG_OPTION_SYSTEM_ZLIB')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like you don't need these two lines since you added FT_CONFIG_OPTION_SYSTEM_ZLIB to the config below?

Copy link
Contributor Author

@HCLJason HCLJason Oct 24, 2022

Choose a reason for hiding this comment

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

I think those might be dead lines. I tried without the highlighted lines, and I got a bunch of duplicate symbol errors when linking.

I'm trying out a build without the config options in the zconf file now.

wasm-ld: error: duplicate symbol: get_crc_table
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(crc32.c.o)

wasm-ld: error: duplicate symbol: crc32_z
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(crc32.c.o)

wasm-ld: error: duplicate symbol: crc32_combine_op
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(crc32.c.o)

wasm-ld: error: duplicate symbol: inflateResetKeep
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(inflate.c.o)

wasm-ld: error: duplicate symbol: inflateInit_
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(inflate.c.o)

wasm-ld: error: duplicate symbol: inflateSyncPoint
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(inflate.c.o)

wasm-ld: error: duplicate symbol: inflateUndermine
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a(ftgzip.c.o)
>>> defined in /local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libz.a(inflate.c.o)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the lines from ftconf.h and leaving this line works.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Whats the difference between ftconf.h and ftoption.h? It seems unfortunate to have to patch a shipping header like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ftconf.h looks like a dead link. ftoption.h is referenced a lot, but there's nothing that uses ftconf.h. I'm trying out a build without ftconf.h to see if that breaks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the ftconfig.h write and file and it built cleanly, so we should be able to remove that entirely.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a lot of stuff in that existing config file. How do we know we are not changing the configuration by removing it? Does freetype no longer use ftconfig.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I double-checked for ftconfig.h and that's actually used in the build, so I reverted that.

The build failure is freetype depending on zlib happening first. How do I denote a dependency?

I tried using the dependency logic referenced in tools/system_libs by adding it to freetype.py, but it didn't seem to work. I see that there's tools/deps_info.py, but that doesn't have any port->port dependencies.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can add deps = ['zlib'] to this file I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change made.

sbc100 added a commit that referenced this pull request Oct 24, 2022
We were previously pointing at a version_1 tag in our custom repo.
This was basically VER-2.6 which a single patch applied.

I can't see anything in that patch that is useful, perhaps this code
didn't previously compile cleanly with emcc but today it seems to work
just fine:

emscripten-ports/FreeType@40a760c

This seems like a good intermediate step before we actually do a
freetype upgrade in #18088.
@sbc100
Copy link
Collaborator

sbc100 commented Oct 24, 2022

I created #18095 which seems like a good intermediate step, and should make the update smaller.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 24, 2022

Were we previously using an internal version of zlib, or not using zlib at all?

'src/base/ftstream.c',
'src/base/ftstroke.c',
'src/base/ftsynth.c',
'src/base/ftsystem.c',
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I use builds/unix/ftsystem.c, the compile is missing the fcntl.h header. It looks like we'll need to pull the #undef HAVE_FCNTL_H from the config file.

/local/emsdk/upstream/emscripten/cache/ports/freetype/freetype-VER-2-12-1/builds/unix/ftsystem.c:258:12: error: call to undeclared function 'open'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    file = open( filepathname, O_RDONLY );
           ^
/local/emsdk/upstream/emscripten/cache/ports/freetype/freetype-VER-2-12-1/builds/unix/ftsystem.c:258:32: error: use of undeclared identifier 'O_RDONLY'
    file = open( filepathname, O_RDONLY );
                               ^
/local/emsdk/upstream/emscripten/cache/ports/freetype/freetype-VER-2-12-1/builds/unix/ftsystem.c:341:22: error: call to undeclared function 'read'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        read_count = read( file,
                     ^
/local/emsdk/upstream/emscripten/cache/ports/freetype/freetype-VER-2-12-1/builds/unix/ftsystem.c:341:22: note: did you mean 'fread'?
/local/emsdk/upstream/emscripten/cache/sysroot/include/stdio.h:106:8: note: 'fread' declared here
size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
       ^
/local/emsdk/upstream/emscripten/cache/ports/freetype/freetype-VER-2-12-1/builds/unix/ftsystem.c:362:5: error: call to undeclared function 'close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    close( file );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some testing. All 3 settings for HAVE_FCNTL_H had build failures with builds/unix/ftsystem.c.

Copy link
Contributor

@ericoporto ericoporto Oct 25, 2022

Choose a reason for hiding this comment

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

Did you check HAVE_UNISTD_H too? It was the only other thing of notice reverse engineering the cmake files...

The methods from the error are here: https://github.com/emscripten-core/emscripten/blob/e05e72d9c49fe15578e73934ce525a894d1b712a/system/lib/libc/musl/include/unistd.h

Copy link
Contributor Author

@HCLJason HCLJason Oct 25, 2022

Choose a reason for hiding this comment

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

I tried #define HAVE_UNISTD_H and HAVE_STDINT_H in the ftconfig.h, and it doesn't work with any of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to be working if I put them in ftoption.h, however.

Copy link
Contributor

@ericoporto ericoporto Oct 26, 2022

Choose a reason for hiding this comment

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

Revising CMake, the full ftconfig.h file should be:

#ifndef FTCONFIG_H_
#define FTCONFIG_H_

#include <ft2build.h>
#include FT_CONFIG_OPTIONS_H
#include FT_CONFIG_STANDARD_LIBRARY_H

#define HAVE_UNISTD_H 1
#define HAVE_FCNTL_H 1

#include <freetype/config/integer-types.h>
#include <freetype/config/public-macros.h>
#include <freetype/config/mac-support.h>

#endif /* FTCONFIG_H_ */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure where the ftconfig.h file in the build script comes from. I looked at the files from 2.6.1 and didn't get anywhere. It doesn't look like the other header files were inlined.

I tried this, and HAVE_UNISTD_H and HAVE_FCNTL_H don't seem to work from ftconfig.h. I'm going to put them back into ftoption.h and see what happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving them in ftoption.h seems to work.

@HCLJason
Copy link
Contributor Author

Were we previously using an internal version of zlib, or not using zlib at all?

I believe that it's using the internal version of zlib.

@HCLJason
Copy link
Contributor Author

I'm looking at the test-other failures. How do we move forward on these?

On my local system, test_freetype failed because it can't find the file LiberationSansBold.ttf.

test_freetype_with_pthreads and test_sdl2_ttf failed because it's looking for the symbol in the wrong place. This is probably a consequence of the zlib change.
error: undefined symbol: inflate (referenced by top-level compiled C/C++ code)

sbc100 added a commit that referenced this pull request Oct 28, 2022
We were previously pointing at a version_1 tag in our custom repo.
This was basically VER-2.6 which a single patch applied.

I can't see anything in that patch that is useful, perhaps this code
didn't previously compile cleanly with emcc but today it seems to work
just fine:

emscripten-ports/FreeType@40a760c

This seems like a good intermediate step before we actually do a
freetype upgrade in #18088.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 18, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 18, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.
@sbc100
Copy link
Collaborator

sbc100 commented Sep 18, 2024

I revived this change recently in the form of #22585.

@HCLJason, what do you think about the updated expected output of the freetype test? It looks like the rendering got a little narrower, but maybe that is normal/expected?

sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 18, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 18, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 19, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 19, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.

Fixes: emscripten-core#22571
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 19, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.

Fixes: emscripten-core#22571
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 19, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.

Fixes: emscripten-core#22571
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 20, 2024
Also, switch from a fork to using the upstream github repo.  We had a
single patch in our fork:

emscripten-ports/FreeType@40a760c

However, this was upstreamed in:

freetype/freetype@2f4b740

This change is based on emscripten-core#18088.

Fixes: emscripten-core#22571
sbc100 added a commit that referenced this pull request Sep 20, 2024
Also, switch from a fork to using the upstream github repo. We had a
single patch in our fork:


emscripten-ports/FreeType@40a760c

However, this was upstreamed in:


freetype/freetype@2f4b740

This change is based on #18088.

Fixes: #22571
@sbc100
Copy link
Collaborator

sbc100 commented Sep 20, 2024

Closing this now that #22585 has landed

@sbc100 sbc100 closed this Sep 20, 2024
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.

3 participants