Skip to content

Commit d15c41a

Browse files
committed
Process --repro early
If mold crashes before --repro is processed, no .repro.tar file is created. So we want to process the option as early as possible.
1 parent b7c8a84 commit d15c41a

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/main.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ int mold_main(int argc, char **argv) {
332332
});
333333
}
334334

335+
// Handle -repro
336+
if (ctx.arg.repro)
337+
write_repro_file(ctx);
338+
335339
Timer t_before_copy(ctx, "before_copy");
336340

337341
// Apply -exclude-libs
@@ -454,10 +458,6 @@ int mold_main(int argc, char **argv) {
454458
if (ctx.arg.print_dependencies)
455459
print_dependencies(ctx);
456460

457-
// Handle -repro
458-
if (ctx.arg.repro)
459-
write_repro_file(ctx);
460-
461461
// Handle --require-defined
462462
for (Symbol<E> *sym : ctx.arg.require_defined)
463463
if (!sym->file)

src/passes.cc

+5-7
Original file line numberDiff line numberDiff line change
@@ -1305,8 +1305,8 @@ void fixup_ctors_in_init_array(Context<E> &ctx) {
13051305
reverse_contents(*isec);
13061306
}
13071307

1308-
template <typename T>
1309-
static void shuffle(std::vector<T> &vec, u64 seed) {
1308+
template <typename E>
1309+
static void shuffle(std::vector<InputSection<E> *> &vec, u64 seed) {
13101310
if (vec.empty())
13111311
return;
13121312

@@ -1402,18 +1402,16 @@ void compute_section_sizes(Context<E> &ctx) {
14021402
Timer t(ctx, "compute_section_sizes");
14031403

14041404
if constexpr (needs_thunk<E>) {
1405-
std::vector<Chunk<E> *> vec = ctx.chunks;
1406-
1407-
auto mid = std::partition(vec.begin(), vec.end(), [&](Chunk<E> *chunk) {
1405+
auto tail = ranges::partition(ctx.chunks, [&](Chunk<E> *chunk) {
14081406
return chunk->to_osec() && (chunk->shdr.sh_flags & SHF_EXECINSTR) &&
14091407
!ctx.arg.relocatable;
14101408
});
14111409

14121410
// create_range_extension_thunks is not thread-safe
1413-
for (Chunk<E> *chunk : std::span(vec.begin(), mid))
1411+
for (Chunk<E> *chunk : std::span(vec.begin(), tail.begin()))
14141412
chunk->to_osec()->create_range_extension_thunks(ctx, true);
14151413

1416-
tbb::parallel_for_each(mid, vec.end(), [&](Chunk<E> *chunk) {
1414+
tbb::parallel_for_each(tail.begin(), tail.end(), [&](Chunk<E> *chunk) {
14171415
chunk->compute_section_size(ctx);
14181416
});
14191417
} else {

0 commit comments

Comments
 (0)