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

Cannot build on macOS: fatal error: 'cassert' file not found #34

Closed
Lorp opened this issue Mar 2, 2021 · 22 comments
Closed

Cannot build on macOS: fatal error: 'cassert' file not found #34

Lorp opened this issue Mar 2, 2021 · 22 comments

Comments

@Lorp
Copy link

Lorp commented Mar 2, 2021

I’m getting this error, trying to build on macOS 10.14.6 :

/Users/lorp/Sites/harfbuzzjs % ./build.sh
In file included from harfbuzz/src/harfbuzz.cc:1:
In file included from harfbuzz/src/hb-aat-layout.cc:28:
harfbuzz/src/hb.hh:179:10: fatal error: 'cassert' file not found
#include <cassert>
         ^~~~~~~~~
1 error generated.

My clang and lld seem to be installed ok.

Any ideas?

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Ugh. That's because of this change:

harfbuzz/harfbuzz@7cb22ba

Can you change back that cassert to assert.h and see which other headers fail there?

@Lorp
Copy link
Author

Lorp commented Mar 2, 2021

Now this happens…

In file included from harfbuzz/src/harfbuzz.cc:1:
In file included from harfbuzz/src/hb-aat-layout.cc:28:
harfbuzz/src/hb.hh:180:10: fatal error: 'cfloat' file not found
#include <cfloat>
         ^~~~~~~~

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Okay I let someone else to chime in. Looks like badly setup toolchain to me. Not sure what harfbuzzjs calls...

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Do you happen to have a newer MacOS version to try?

@behdad
Copy link
Member

behdad commented Mar 2, 2021

I get a ton of other errors when I try to compile the way you are...

@Lorp
Copy link
Author

Lorp commented Mar 2, 2021

I don’t have a newer macOS version right now.

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Does it work if you revert that HarfBuzz commit?

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Something's definitely wrong with how harfbuzzjs invokes the compiler. I can't get it work here though.

@Lorp
Copy link
Author

Lorp commented Mar 2, 2021

With the previous dbcf2f4 I get:

/Users/lorp/Sites/harfbuzzjs % ./build.sh
In file included from harfbuzz/src/harfbuzz.cc:1:
In file included from harfbuzz/src/hb-aat-layout.cc:35:
In file included from harfbuzz/src/hb-aat-layout-kerx-table.hh:31:
In file included from harfbuzz/src/hb-kern.hh:32:
In file included from harfbuzz/src/hb-ot-layout-gpos-table.hh:32:
harfbuzz/src/hb-ot-layout-gsubgpos.hh:3437:15: error: use of undeclared identifier 'alternate_feature_indices'
          && !alternate_feature_indices.has (i))
              ^
1 error generated.

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Did running this "./build.sh" ever worked for you?

Maybe @ebraminio can respond.

@Lorp
Copy link
Author

Lorp commented Mar 2, 2021

No, this is the first time. I am intending to compile with variations on.

@ebraminio
Copy link
Contributor

Headers issue is resolved however there are apparently other issues upstream side,

$ gcc src/harfbuzz.cc -DHB_TINY
In file included from src/hb-ot-layout-gpos-table.hh:32,
                 from src/hb-kern.hh:32,
                 from src/hb-aat-layout-kerx-table.hh:31,
                 from src/hb-aat-layout.cc:35,
                 from src/harfbuzz.cc:1:
src/hb-ot-layout-gsubgpos.hh: In member function ‘void OT::GSUBGPOS::prune_features(const hb_map_t*, hb_set_t*) const’:
src/hb-ot-layout-gsubgpos.hh:3437:15: error: ‘alternate_feature_indices’ was not declared in this scope
 3437 |           && !alternate_feature_indices.has (i))
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~

Apparently ArchLinux CI which also was testing HB_TINY and flake8 testing harfbuzz/harfbuzz@094406b is disabled.

@behdad
Copy link
Member

behdad commented Mar 2, 2021

Ah... it didn't occur to me that the wasm toolchain doesn't come with any standard headers. Thanks Ebrahim. I'll fix the other issue.

@ebraminio
Copy link
Contributor

ebraminio commented Mar 2, 2021

@Lorp, just note on macOS you'll need to put brew installed clang on PATH instead toolchain brought one as the latter isn't updated enough unfortunately. In order to enable variation you'll need to apply the below patch but that's just the start as you'll need to wire up the variation APIs to .wasm (simply adding them to build.sh API listing part) and then use it on .js/.ts wrapper if you need it and don't use .wasm directly. We can work on it ofc but patches are also welcomed,

diff --git a/config-override.h b/config-override.h
index 4366421..a5062ad 100644
--- a/config-override.h
+++ b/config-override.h
@@ -4,3 +4,4 @@
 #undef HB_NO_DRAW
 #undef HB_NO_BUFFER_MESSAGE
 #undef HB_NO_BUFFER_SERIALIZE
+#undef HB_NO_VAR

Have a look at https://harfbuzz.github.io/harfbuzzjs/ also as a [at least supposed to] simple demo

@Lorp
Copy link
Author

Lorp commented Mar 3, 2021

Hey @ebraminio & @behdad, thanks for the commits. It now builds and runs well, and also builds & runs when I edit config-override.h to add #undef HB_NO_VAR and export 3 variations functions in build.sh:

-Wl,--export=hb_ot_var_get_axis_count \
-Wl,--export=hb_ot_var_get_axis_infos \
-Wl,--export=hb_font_set_variations \

Then I added a getAxisCount() method in createFace() (in hbjs.js), which works perfectly :)

getAxisCount: function () {
  return exports.hb_ot_var_get_axis_count(ptr);
},

But I cannot seem to pass non-integer parameters, so I have not got hb_ot_var_get_axis_infos() or hb_font_set_variations() working. Maybe I have to pack the structures they need into blobs.

@Lorp
Copy link
Author

Lorp commented Mar 3, 2021

My attempts:

// hbjs.js [in createFace()]
getAxisInfos: function (start_offset, axes_count_ptr, axes_array) {
  return exports.hb_ot_var_get_axis_infos(ptr, start_offset, axes_count_ptr, axes_array);
},

// hbjs.js [in createFont()]
setVariations: function (variations, variations_length) {
  exports.hb_font_set_variations(ptr, variations, variations_length);
},

// harfbuzzjs.html
let axisInfos = [];
let numAxesPtr = [numAxes]; // numAxes == 2
face.getAxisInfos(0, numAxesPtr, axisInfos);
let variations = [{tag:"wght", value: 800.0}, {tag:"wdth", value: 666.7}];
font.setVariations(variations, 2);

@ebraminio
Copy link
Contributor

oh, wasm machine doesn't understand complex js structures, am trying to make it work for you :)

@ebraminio
Copy link
Contributor

@Lorp: cc798e5 here you go :)

@Lorp
Copy link
Author

Lorp commented Mar 5, 2021

That works perfectly! Thanks very much!

face.getAxisInfos() from Recursive-VariableFont_CASL,CRSV,MONO,slnt,wght.ttf:

{MONO: {min: 0, default: 0, max: 1}, CASL: {min: 0, default: 0, max: 1}, wght: {min: 300, default: 300, max: 1000}, slnt: {min: -15, default: 0, max: 0}, CRSV: {min: 0, default: 0.5, max: 1}}

Recursive-wght-300-CASL-0
Recursive-wght-1000-CASL-1

@Lorp
Copy link
Author

Lorp commented Mar 8, 2021

Is it possible to apply features?

From hbjs.example.js:

hb.shape(font, buffer); // features are not supported yet

@ebraminio
Copy link
Contributor

ebraminio commented Mar 8, 2021

Is it possible to apply features?

Apparently we only have implemented it for shapeWithTrace https://github.com/harfbuzz/harfbuzzjs/blob/cc798e5/hbjs.js#L337 and not with the main https://github.com/harfbuzz/harfbuzzjs/blob/cc798e5/hbjs.js#L315 guess for now you can use shapeWithTrace and get a GSUB/GPOS applying steps trace also for free, the API is already used in https://github.com/simoncozens/crowbar, till one implements the same for shape() also.

@Lorp
Copy link
Author

Lorp commented Mar 9, 2021

Success! It was failing when I constructed features as an object, but then I realized it must be a string. CSS syntax with on and off, single or double quotes, and comma separation works perfectly :)

let features = "'kern' off, 'frac' on";
hb.shapeWithTrace(font, buffer, features);
let result = buffer.json(font);

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