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

[browser][publish] Windows has problems with AOT build/publish for long paths #103766

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ mono_debugger_agent_init_internal (void)
disconnected = TRUE;

if (agent_config.log_file) {
log_file = fopen (agent_config.log_file, "w+");
log_file = g_fopen (agent_config.log_file, "w+");
if (!log_file) {
PRINT_ERROR_MSG ("Unable to create log file '%s': %s.\n", agent_config.log_file, strerror (errno));
exit (1);
Expand Down
17 changes: 14 additions & 3 deletions src/mono/mono/eglib/gfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,20 @@ g_fopen (const gchar *path, const gchar *mode)
return NULL;

#ifdef HOST_WIN32
if (is_ascii_string (path) && is_ascii_string (mode)) {
fp = fopen (path, mode);
gchar *path_mod;
if (g_path_is_absolute (path)) {
path_mod = g_malloc(strlen(path) + 5);
strcpy(path_mod, "\\\\?\\");
strcat(path_mod, path);
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved
} else {
gunichar2 *wPath = g_utf8_to_utf16 (path, -1, 0, 0, 0);
path_mod = g_malloc(strlen(path));
strcpy(path_mod, path);
}

if (is_ascii_string (path_mod) && is_ascii_string (mode)) {
fp = fopen (path_mod, mode);
} else {
gunichar2 *wPath = g_utf8_to_utf16 (path_mod, -1, 0, 0, 0);
gunichar2 *wMode = g_utf8_to_utf16 (mode, -1, 0, 0, 0);

if (!wPath || !wMode)
Expand All @@ -140,6 +150,7 @@ g_fopen (const gchar *path, const gchar *mode)
g_free (wPath);
g_free (wMode);
}
g_free (path_mod);
#else
fp = fopen (path, mode);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/eventpipe/ds-rt-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ ipc_get_process_id_disambiguation_key (
char stat_file_name [64];
snprintf (stat_file_name, sizeof (stat_file_name), "/proc/%d/stat", process_id);

FILE *stat_file = fopen (stat_file_name, "r");
FILE *stat_file = g_fopen (stat_file_name, "r");
if (!stat_file) {
EP_ASSERT (!"Failed to get start time of a process, fopen failed.");
EP_ASSERT (!"Failed to get start time of a process, g_fopen failed.");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/lock-tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mono_locks_tracer_init (void)
return;

name = g_strdup_printf ("locks.%d", getpid ());
trace_file = fopen (name, "w+");
trace_file = g_fopen (name, "w+");
g_free (name);

#ifdef TARGET_OSX
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/seq-points-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ mono_seq_point_data_read (SeqPointData *data, char *path)
long fsize;
FILE *f;

f = fopen (path, "r");
f = g_fopen (path, "r");
if (!f)
return FALSE;

Expand Down Expand Up @@ -440,7 +440,7 @@ mono_seq_point_data_write (SeqPointData *data, char *path)
FILE *f;
int i, size = 0;

f = fopen (path, "w+");
f = g_fopen (path, "w+");
if (!f)
return FALSE;

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/sgen-new-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ dump_graph (void)
int edge_id = 0;

sprintf (filename, "%s.%d.gexf", dump_prefix, counter++);
file = fopen (filename, "w");
file = g_fopen (filename, "w");

if (file == NULL) {
fprintf (stderr, "Warning: Could not open bridge dump file `%s` for writing: %s\n", filename, strerror (errno));
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,7 @@ mono_threads_perform_thread_dump (void)
strftime(time_str, sizeof(time_str), MONO_STRFTIME_F "_" MONO_STRFTIME_T, &tod);
ms = tv.tv_usec / 1000;
g_string_append_printf (path, "%s/%s.%03ld.tdump", thread_dump_dir, time_str, ms);
output_file = fopen (path->str, "w");
output_file = g_fopen (path->str, "w");
g_string_free (path, TRUE);
}
if (output_file == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -15705,7 +15705,7 @@ compile_assemblies_in_child (MonoAotOptions *aot_opts, MonoAssembly **assemblies
#ifdef HOST_WIN32
response_fname = g_build_filename (aot_opts->temp_path, "temp.rsp", (const char*)NULL);
g_assert (response_fname);
response = fopen (response_fname, "w");
response = g_fopen (response_fname, "w");
g_assert (response);
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ mono_main (int argc, char* argv[])
fprintf (stderr, "error: --statfile requires a filename argument\n");
return 1;
}
mini_stats_fd = fopen (argv [++i], "w+");
mini_stats_fd = g_fopen (argv [++i], "w+");
} else if (strncmp (argv [i], "--optimize=", 11) == 0) {
opt = parse_optimizations (opt, argv [i] + 11, TRUE);
} else if (strncmp (argv [i], "-O=", 3) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ mono_draw_graph (MonoCompile *cfg, MonoGraphOptions draw_options)
FILE *fp;

fn = "/tmp/minidtree.graph";
fp = fopen (fn, "w+");
fp = g_fopen (fn, "w+");
g_assert (fp);

switch (draw_options) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
#ifdef HOST_WIN32
as_file = g_strdup_printf ("%s/test.s", tmp);

if (!(ofd = fopen (as_file, "w")))
if (!(ofd = g_fopen (as_file, "w")))
g_assert_not_reached ();
#else
i = g_file_open_tmp (NULL, &as_file, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/mini-ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ mono_arch_init (void)
AuxVec vec [MAX_AUX_ENTRIES];
int i, vec_entries = 0;
/* sadly this will work only with 2.6 kernels... */
FILE* f = fopen ("/proc/self/auxv", "rb");
FILE* f = g_fopen ("/proc/self/auxv", "rb");

if (f) {
vec_entries = fread (&vec, sizeof (AuxVec), MAX_AUX_ENTRIES, f);
Expand Down
6 changes: 3 additions & 3 deletions src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ mono_enable_jit_map (void)
char name [64];
g_snprintf (name, sizeof (name), "/tmp/perf-%d.map", getpid ());
unlink (name);
perf_map_file = fopen (name, "w");
perf_map_file = g_fopen (name, "w");
}
}

Expand Down Expand Up @@ -2115,7 +2115,7 @@ mono_enable_jit_dump (void)

g_snprintf (name, sizeof (name), "/tmp/jit-%d.dump", perf_dump_pid);
unlink (name);
perf_dump_file = fopen (name, "w+");
perf_dump_file = g_fopen (name, "w+");

add_file_header_info (&header);
if (perf_dump_file) {
Expand Down Expand Up @@ -3151,7 +3151,7 @@ mono_set_bisect_methods (guint32 opt, const char *method_list_filename)
bisect_methods_hash = g_hash_table_new (g_str_hash, g_str_equal);
g_assert (bisect_methods_hash);

file = fopen (method_list_filename, "r");
file = g_fopen (method_list_filename, "r");
g_assert (file);

while (fgets (method_name, sizeof (method_name), file)) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/profiler/aot.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ mono_profiler_init_aot (const char *desc)
} else if (*aot_profiler.outfile_name == '#') {
aot_profiler.outfile = fdopen (strtol (aot_profiler.outfile_name + 1, NULL, 10), "a");
} else {
aot_profiler.outfile = fopen (aot_profiler.outfile_name, "w");
aot_profiler.outfile = g_fopen (aot_profiler.outfile_name, "w");
}

if (!aot_profiler.outfile && aot_profiler.outfile_name) {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/profiler/coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ get_file_content (const gchar *filename)
int res, offset = 0;
FILE *stream;

stream = fopen (filename, "r");
stream = g_fopen (filename, "r");
if (stream == NULL)
return NULL;

Expand Down Expand Up @@ -1170,7 +1170,7 @@ mono_profiler_init_coverage (const char *desc)
} else if (*coverage_config.output_filename == '#') {
coverage_profiler.file = fdopen (strtol (coverage_config.output_filename + 1, NULL, 10), "a");
} else {
coverage_profiler.file = fopen (coverage_config.output_filename, "w");
coverage_profiler.file = g_fopen (coverage_config.output_filename, "w");
}

if (!coverage_profiler.file) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/profiler/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -3602,7 +3602,7 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
int fd = strtol (nf + 1, NULL, 10);
log_profiler.file = fdopen (fd, "a");
} else
log_profiler.file = fopen (nf, "wb");
log_profiler.file = g_fopen (nf, "wb");

if (!log_profiler.file) {
mono_profiler_printf_err ("Could not create log profiler output file '%s': %s", nf, g_strerror (errno));
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/profiler/mprof-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -3232,7 +3232,7 @@ load_file (char *name)
if (strcmp (name, "-") == 0)
ctx->file = stdin;
else
ctx->file = fopen (name, "rb");
ctx->file = g_fopen (name, "rb");
if (!ctx->file) {
printf ("Cannot open file: %s\n", name);
exit (1);
Expand Down Expand Up @@ -4070,7 +4070,7 @@ main (int argc, char *argv[])
reports = val;
} else if (strncmp ("--out=", argv [i], 6) == 0) {
const char *val = argv [i] + 6;
outfile = fopen (val, "w");
outfile = g_fopen (val, "w");
if (!outfile) {
printf ("Cannot open output file: %s\n", val);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/sgen/sgen-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ dump_object_callback (GCObject *obj, size_t size, gboolean dump_location)
void
sgen_debug_enable_heap_dump (const char *filename)
{
heap_dump_file = fopen (filename, "w");
heap_dump_file = g_fopen (filename, "w");
if (heap_dump_file) {
fprintf (heap_dump_file, "<sgen-dump>\n");
sgen_pin_stats_enable ();
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/sgen/sgen-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3753,7 +3753,7 @@ sgen_gc_init (void)
opt++;
if (opt [0]) {
char *rf = g_strdup_printf ("%s.%d", opt, mono_process_current_pid ());
sgen_gc_debug_file = fopen (rf, "wb");
sgen_gc_debug_file = g_fopen (rf, "wb");
if (!sgen_gc_debug_file)
sgen_gc_debug_file = stderr;
g_free (rf);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/tests/metadata-verifier/gen-md-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ test_validity_name (int validity)
static char*
read_whole_file_and_close (const char *name, int *file_size)
{
FILE *file = fopen (name, "ro");
FILE *file = g_fopen (name, "ro");
char *res;
int fsize;

Expand Down Expand Up @@ -592,7 +592,7 @@ process_test_entry (test_set_t *test_set, test_entry_t *entry)

file_name = make_test_name (entry, test_set);

f = fopen (file_name, "wo");
f = g_fopen (file_name, "wo");
fwrite (entry->data, entry->data_size, 1, f);
fclose (f);

Expand Down
14 changes: 7 additions & 7 deletions src/mono/mono/utils/mono-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ readMemoryValueFromFile(const char* filename, size_t* val)
FILE *file = NULL;

if (val != NULL) {
file = fopen (filename, "r");
file = g_fopen (filename, "r");
if (file != NULL) {
if (getline (&line, &lineLen, file) != -1) {
errno = 0;
Expand Down Expand Up @@ -337,7 +337,7 @@ findHierarchyMount(gboolean (*is_subsystem)(const char *), char** pmountpath, ch
char *mountpath = NULL;
char *mountroot = NULL;

FILE *mountinfofile = fopen (PROC_MOUNTINFO_FILENAME, "r");
FILE *mountinfofile = g_fopen (PROC_MOUNTINFO_FILENAME, "r");
if (mountinfofile == NULL)
goto done;

Expand Down Expand Up @@ -432,7 +432,7 @@ findCGroupPathForSubsystem(gboolean (*is_subsystem)(const char *))
char *cgroup_path = NULL;
gboolean result = FALSE;

FILE *cgroupfile = fopen (PROC_CGROUP_FILENAME, "r");
FILE *cgroupfile = g_fopen (PROC_CGROUP_FILENAME, "r");
if (cgroupfile == NULL)
goto done;

Expand Down Expand Up @@ -568,7 +568,7 @@ getCGroupMemoryUsage(size_t *val, const char *filename, const char *inactiveFile
if (asprintf (&stat_filename, "%s%s", s_memory_cgroup_path, CGROUP_MEMORY_STAT_FILENAME) < 0)
return FALSE;

FILE *stat_file = fopen (stat_filename, "r");
FILE *stat_file = g_fopen (stat_filename, "r");
free (stat_filename);
if (stat_file == NULL)
return FALSE;
Expand Down Expand Up @@ -689,7 +689,7 @@ mono_get_memory_used(size_t *val)
return TRUE;

// process resident set size.
FILE* file = fopen (PROC_STATM_FILENAME, "r");
FILE* file = g_fopen (PROC_STATM_FILENAME, "r");
if (file != NULL && getline (&line, &linelen, file) != -1) {
char* context = NULL;
char* strTok = strtok_r (line, " ", &context);
Expand Down Expand Up @@ -799,7 +799,7 @@ getCGroup2CpuLimit(guint32 *val)
if (asprintf (&filename, "%s%s", s_cpu_cgroup_path, CGROUP2_CPU_MAX_FILENAME) < 0)
return FALSE;

file = fopen (filename, "r");
file = g_fopen (filename, "r");
if (file == NULL)
goto done;

Expand Down Expand Up @@ -922,7 +922,7 @@ readLongLongValueFromFile(const char *filename, long long *val)
if (val == NULL)
return FALSE;

FILE *file = fopen (filename, "r");
FILE *file = g_fopen (filename, "r");
if (file == NULL)
return FALSE;

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ get_dl_name_from_libtool (const char *libtool_file)
FILE* file;
char buf [512];
char *line, *dlname = NULL, *libdir = NULL, *installed = NULL;
if (!(file = fopen (libtool_file, "r")))
if (!(file = g_fopen (libtool_file, "r")))
return NULL;
while ((line = fgets (buf, 512, file))) {
while (*line && isspace (*line))
Expand Down
14 changes: 12 additions & 2 deletions src/mono/mono/utils/mono-filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@
MonoFileMap *
mono_file_map_open (const char* name)
{
#ifdef WIN32
gunichar2 *wname = g_utf8_to_utf16 (name, -1, 0, 0, 0);
#ifdef HOST_WIN32
gchar *name_mod;
if (g_path_is_absolute (name)) {
name_mod = g_malloc(strlen(name) + 5);
strcpy(name_mod, "\\\\?\\");
strcat(name_mod, name);
} else {
name_mod = g_malloc(strlen(name));
strcpy(name_mod, name);
}
gunichar2 *wname = g_utf8_to_utf16 (name_mod, -1, 0, 0, 0);
MonoFileMap *result;

if (wname == NULL)
return NULL;
result = (MonoFileMap *) _wfopen ((wchar_t *) wname, L"rb");
g_free (name_mod);
g_free (wname);
return result;
#else
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-hwcap-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ mono_hwcap_arch_init (void)
char buf [512];
char *line;

FILE *file = fopen ("/proc/cpuinfo", "r");
FILE *file = g_fopen ("/proc/cpuinfo", "r");

if (file) {
while ((line = fgets (buf, 512, file))) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-log-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mono_log_open_logfile(const char *path, void *userData)
logFile = stdout;
} else {
#ifndef HOST_WIN32
logFile = fopen(path, "w");
logFile = g_fopen(path, "w");
#else
gunichar2 *wPath = g_utf8_to_utf16(path, -1, 0, 0, 0);
if (wPath != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ mono_sha1_get_digest_from_file (const gchar *filename, guchar digest [20])
FILE *fp;

mono_sha1_init (&ctx);
fp = fopen(filename, "r");
fp = g_fopen(filename, "r");
if (!fp) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-threads-android.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void
slow_get_thread_bounds (guint8 *current, guint8 **staddr, size_t *stsize)
{
char buff [1024];
FILE *f = fopen ("/proc/self/maps", "r");
FILE *f = g_fopen ("/proc/self/maps", "r");
if (!f)
g_error ("Could not determine thread bounds, failed to open /proc/self/maps");

Expand Down
Loading
Loading