- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.4k
Update freetype.py to 2.12.1 #18088
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
Update freetype.py to 2.12.1 #18088
Conversation
        
          
                tools/ports/freetype.py
              
                Outdated
          
        
      | 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') | 
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change made.
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.
| I created #18095 which seems like a good intermediate step, and should make the update smaller. | 
| Were we previously using an internal version of zlib, or not using zlib at all? | 
        
          
                tools/ports/freetype.py
              
                Outdated
          
        
      | 'src/base/ftstream.c', | ||
| 'src/base/ftstroke.c', | ||
| 'src/base/ftsynth.c', | ||
| 'src/base/ftsystem.c', | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be builds/unix/ftsystem.c
see:
| set(UNIX 1) | 
https://gitlab.freedesktop.org/freetype/freetype/-/blob/VER-2-12-1/CMakeLists.txt#L415
There was a problem hiding this comment.
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 );
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_ */There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 
 I believe that it's using the internal version of zlib. | 
The defines don't work in ftconfig.h, but they work in ftoption.h.
| 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. | 
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.
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.
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.
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.
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.
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.
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
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
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
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
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
| Closing this now that #22585 has landed | 
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.