srl295/node — pull request #15 by misterdjules (2014-12-12 07:03:18+00:00)
Title: build: support --icu-data-dir configure switch

A few comments about this PR:
* We may want to remove the usage of `--icu-data-dir` in the `Makefile`'s target that builds the OS X package, since we haven't solved the cross-compilation issue (see #12) yet and we need it for OS X packages.

* It seems that our current V8 doesn't handle the situation when ICU is linked with only the stubbed data and the .dat file cannot be found. It segfaults with the following call stack:
```
* thread #1: tid = 0x266c56, 0x000000010035a5b3 node`v8::internal::(anonymous namespace)::SetResolvedDateSettings(isolate=0x0000000101804c00, icu_locale=0x00007fff5fbfea80, date_format=0x0000000000000000, resolved=) + 99 at i18n.cc:132, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x000000010035a5b3 node`v8::internal::(anonymous namespace)::SetResolvedDateSettings(isolate=0x0000000101804c00, icu_locale=0x00007fff5fbfea80, date_format=0x0000000000000000, resolved=) + 99 at i18n.cc:132
129	Factory* factory = isolate->factory();
130	UErrorCode status = U_ZERO_ERROR;
131	icu::UnicodeString pattern;
-> 132	date_format->toPattern(pattern);
133	JSObject::SetProperty(
134	resolved,
135	factory->NewStringFromStaticAscii("pattern"),
(lldb) bt
* thread #1: tid = 0x266c56, 0x000000010035a5b3 node`v8::internal::(anonymous namespace)::SetResolvedDateSettings(isolate=0x0000000101804c00, icu_locale=0x00007fff5fbfea80, date_format=0x0000000000000000, resolved=) + 99 at i18n.cc:132, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x000000010035a5b3 node`v8::internal::(anonymous namespace)::SetResolvedDateSettings(isolate=0x0000000101804c00, icu_locale=0x00007fff5fbfea80, date_format=0x0000000000000000, resolved=) + 99 at i18n.cc:132
frame #1: 0x000000010035a351 node`v8::internal::DateFormat::InitializeDateTimeFormat(isolate=0x0000000101804c00, locale=, options=, resolved=) + 353 at i18n.cc:775
frame #2: 0x000000010045bdaa node`v8::internal::Runtime_CreateDateTimeFormat(int, v8::internal::Object**, v8::internal::Isolate*) [inlined] v8::internal::__RT_impl_Runtime_CreateDateTimeFormat(isolate=0x0000000101804c00, arguments=0x00007fff5fbff048) + 185 at runtime.cc:14055
frame #3: 0x000000010045bcf1 node`v8::internal::Runtime_CreateDateTimeFormat(args_length=, args_object=0x00007fff5fbff048, isolate=0x0000000101804c00) + 17 at runtime.cc:14036
frame #4: 0x000027480ab0740e
frame #5: 0x000027480aba9d00
frame #6: 0x000027480aba9688
frame #7: 0x000027480ab07b75
frame #8: 0x000027480ab32de2
frame #9: 0x000027480aba94bf
frame #10: 0x000027480aba7d03
frame #11: 0x000027480aba7ac9
frame #12: 0x000027480ab07b75
frame #13: 0x000027480aba55e7
frame #14: 0x000027480ab5e0a6
frame #15: 0x000027480aba43a6
frame #16: 0x000027480ab9e9ac
frame #17: 0x000027480ab9b1e0
frame #18: 0x000027480ab91d45
frame #19: 0x000027480ab91704
frame #20: 0x000027480ab6451f
frame #21: 0x000027480ab62f10
frame #22: 0x000027480ab5b1c0
frame #23: 0x000027480ab28d31
frame #24: 0x0000000100210603 node`v8::internal::Invoke(is_construct=, argc=1, args=0x00007fff5fbff7f8, function=, receiver=) + 419 at execution.cc:91
frame #25: 0x0000000100123d6f node`v8::Function::Call(this=0x0000000101858418, argc=1, argv=0x00007fff5fbff7f8, recv=) + 207 at api.cc:4019
frame #26: 0x0000000100541ce9 node`node::LoadEnvironment(env=0x0000000101803000) + 517 at node.cc:2868
frame #27: 0x0000000100542f0a node`node::Start(argc=2, argv=) + 305 at node.cc:3696
frame #28: 0x0000000100000b74 node`start + 52
(lldb)
```
It seems that we should at least make V8 exits more gracefully with an error message that indicates the cause of the error.

* Defining the `ICU_DATA_DIR` macro with a relative path cannot work, as ICU would try to load the `.dat` file relative to the current working directory. Thus, the `configure` script either needs to always get an absolute path for `--icu-data-dir`, or it needs to know about the installation prefix. This is why in this PR the prefix definition has been moved from `Makefile` to `configure`.

Fixes #13.